Hi all,
I found this code snipet that's supposed to return the iPhone's IP
address.
I am wondering if anyone can confirm the method for me.
As i am told that this method works in an actual iPhone and not on the
simulator.
But i won't have an iPhone until Aug 9th....
All i am getting in the simulator is something like : "fe80::21e:
52ff:fec6:b7401.618407e-303n1"
I am wondering if anyone can confirm the method works (ie, returns an
actual ip address) on an actual iPhone for me....
The code:
- (NSString*) getNetAddr {
char iphone_ip[255];
strcpy(iphone_ip,"127.0.0.1"); // if everything fails
NSHost *myhost =[NSHost currentHost];
//NSHost *myhost = [[NSHost alloc] init];
if (myhost)
{
NSLog(@"myhost exits");
NSString *ad = [myhost address];
if (ad)
strcpy(iphone_ip, [ad cStringUsingEncoding:
NSISOLatin1StringEncoding]);
}
return [NSString stringWithFormat:@"%s", iphone_ip];
}
Thank you in advance...
James
_______________________________________________
Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)
Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com
Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com
This email sent to arch...@mail-archive.com