我想在一个应用程序中找到IP地址。我能够找到它。但是问题是,在iPhone OS 2.0或更早版本中可以正常工作。但是,在iPhone OS 3.0中,它会给我一个警告:
warning: no '+currentHost' method found
warning: (Messages without a matching method signature)
我正在使用这段代码,在操作系统版本为2.0时可以正常工作。
-(NSString*)getAddress {
char iphone_ip[255];
strcpy(iphone_ip,"127.0.0.1"); // if everything fails
NSHost* myhost = [NSHost currentHost];
if (myhost)
{
NSString *ad = [myhost address];
if (ad)
strcpy(iphone_ip,[ad cStringUsingEncoding: NSISOLatin1StringEncoding]);
}
return [NSString stringWithFormat:@"%s",iphone_ip];
如何在iPhone OS 3.0或更高版本中查找IP地址?
提前感谢。