nshost

NSHost “currentHost” not recognized

孤者浪人 提交于 2020-01-15 10:49:46
问题 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

Find IP address in iphone

三世轮回 提交于 2019-12-18 15:57:06
问题 I want to find IP address in an application. I am able to find it. But, problem is, it works fins in iphone os 2.0 or so. But, in iphone os 3.0 it is giving me a warning: warning: no '+currentHost' method found warning: (Messages without a matching method signature) I am using this code, and it works fine with os version 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 =

Alternatives to NSHost in iPhone app

可紊 提交于 2019-12-17 19:01:02
问题 I'm currently using this code NSHost *host = [NSHost hostWithAddress:hostname]; if (host == nil) { host = [NSHost hostWithName:hostname]; if (host == nil) { [self setMessage:@"Invalid IP address or hostname:"]; return; } } to retrive my IP Address for a networking app I'm working on, however I'm aware that NSHost is a private API that will be rejected. Can anyone help me with working this code to produce the same results without using NSHost? I'm not really sure where to start. EDIT:

I tried to use NSHost and XCode didn't recognize it

最后都变了- 提交于 2019-12-12 02:28:45
问题 I tried to add an NSHost method and XCode didn't recognize it. Do you know why this happened? 回答1: Your question is tagged with iPhone; NSHost is not available on the iPhone. NSHost is Mac OS X only. Here is an alternative solution to using NSHost: Alternatives to NSHost in iPhone app 回答2: NSHost is not supported for iPhone. Read apple's technical note http://developer.apple.com/library/ios/#qa/qa1652/_index.html 回答3: iPhone SDK does not support NSHost. But you can use this alternative

NSHost run in device gives an NSHost.h error

我怕爱的太早我们不能终老 提交于 2019-12-12 01:15:21
问题 NSHost doesnot support to iphone... When I run this in simulator it works fine... But when I want to run in device means it gives an NSHost.h error.... I want to do this in device also. How could I fix this? 回答1: NSHost is a private API on the iPhone and is thus not supported on the actual device. 回答2: Apple have published a technical note (QA1652) on "Using NSStreams For A TCP Connection Without NSHost." There's a code sample on that page, but here's a summary: You can do this by exploiting

Find IP address in iphone

廉价感情. 提交于 2019-11-30 13:42:20
I want to find IP address in an application. I am able to find it. But, problem is, it works fins in iphone os 2.0 or so. But, in iphone os 3.0 it is giving me a warning: warning: no '+currentHost' method found warning: (Messages without a matching method signature) I am using this code, and it works fine with os version 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]); }

Alternatives to NSHost in iPhone app

时光总嘲笑我的痴心妄想 提交于 2019-11-28 09:29:22
I'm currently using this code NSHost *host = [NSHost hostWithAddress:hostname]; if (host == nil) { host = [NSHost hostWithName:hostname]; if (host == nil) { [self setMessage:@"Invalid IP address or hostname:"]; return; } } to retrive my IP Address for a networking app I'm working on, however I'm aware that NSHost is a private API that will be rejected. Can anyone help me with working this code to produce the same results without using NSHost? I'm not really sure where to start. EDIT: Following suggestions that seem damn near perfect below I've added this code into my app in the place of the

Accessing IP Address with NSHost

允我心安 提交于 2019-11-28 09:28:32
I am trying to get the IP Address using NSHost . With the NSHost object I can use the addresses method to access an array of objects one of which is the IP Address. I fear though that the IP Address may change position in the array from one machine to the other. Is there a way to access this information in a universal way? There was an attempt to answer this question in a previous post, but as you can see it falls short. IP Address? - Cocoa Here is my code: +(NSString *) ipAddress { NSHost * h = [[[NSHost currentHost] addresses] objectAtIndex:1]; return h ; } I have used this on many machines

Accessing IP Address with NSHost

ぐ巨炮叔叔 提交于 2019-11-27 02:57:02
问题 I am trying to get the IP Address using NSHost . With the NSHost object I can use the addresses method to access an array of objects one of which is the IP Address. I fear though that the IP Address may change position in the array from one machine to the other. Is there a way to access this information in a universal way? There was an attempt to answer this question in a previous post, but as you can see it falls short. IP Address? - Cocoa Here is my code: +(NSString *) ipAddress { NSHost *