アプリケーションで IP アドレスを検索したい。私はそれを見つけることができます。しかし、問題は、それが iphone os 2.0 かそこらで動作することです。しかし、iphone os 3.0 では警告が表示されます。
warning: no '+currentHost' method found
warning: (Messages without a matching method signature)
このコードを使用していますが、OS バージョン 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以降のOSバージョンでIPアドレスを見つける方法は?
前もって感謝します。