以下是CocoaChina会员 “ijawfx” 分享的XCode里查询本机IP的Objective-C代码,帖子地址http://www.cocoachina.com/bbs/read.php?tid-19634.html
NSHost* myhost =[NSHost currentHost];
NSString *ad = [myhost address];
字符串ad的值就是你的本机ip。
NSHost* myhost =[NSHost currentHost];
NSString *ad = [myhost address];
字符串ad的值就是你的本机ip。