getting ip address in iphone development

NSString*  ip=@“http://www.whatismyip.org/”;

NSURL *url = [[NSURL alloc] initWithString:ip];

NSString *ans = [NSString stringWithContentsOfURL:url encoding:NSASCIIStringEncoding error:&error];

NSLog(@“%@”,ans);

one more method

 

 

Import UIDevice-Reachability.h in your project then try with one of those commands:

NSString *myIp = [UIDevice localIPAddress];

NSString *myIp = [UIDevice localWiFiIPAddress];

NSString *myIp = [UIDevice whatismyipdotcom];

 

Comments

comments

One Reply to “getting ip address in iphone development”

Leave a Reply

Your email address will not be published. Required fields are marked *