i'd like to use this code to know my ip, but i got 2 warnings that i can't fix for now. I also found this post : Accessing IP Address with NSHost
but i just wanted to understand why this code does not work, if anyone has an answer?
here's my code :
-(NSString*)getAddress { NSString *iphone_ip = [NSString initWithString:@"127.0.0.1"]; NSHost* myhost =[NSHost currentHost]; if (myhost) { NSString *ad = [myhost address]; if (ad) strcpy(iphone_ip,[ad cStringUsingEncoding: NSISOLatin1StringEncoding]); } return [NSString stringWithFormat:@"%s",iphone_ip]; }
the first warning is on :
NSHost* myhost =[NSHost currentHost]
, saying that currentHost is not recognised. The second one is on
NSString *ad = [myhost address];
" incompatible obj-c types initializing 'struct NSData ", expected 'struct NString" "
I can imagine the second warning might disappear when the first warning is resolved...
Thanks for your help
Paul