• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Re: [iPhone] get iPhone's IP address...
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [iPhone] get iPhone's IP address...


  • Subject: Re: [iPhone] get iPhone's IP address...
  • From: Luke Hiesterman <email@hidden>
  • Date: Mon, 20 Jul 2009 07:51:07 -0700

I should also have mentioned that you should be able to get the functionality you need via CFHost.

Luke

Sent from my iPhone.

On Jul 20, 2009, at 6:33 AM, Luke Hiesterman <email@hidden> wrote:

Please note that NSHost is NOT publicly supported API on iPhone. Attempts to use it may result in unexpected behavior and broken applications in future iPhone revisions. Also, using private classes is a breach of the iPhone developer terms and conditions. Finally, using a private class such as NSHost should not be discussed on this list.

Luke

Sent from my iPhone.

On Jul 19, 2009, at 10:50 PM, James Lin <email@hidden> wrote:

Hi all,

I found this code snipet that's supposed to return the iPhone's IP address.

I am wondering if anyone can confirm the method for me.
As i am told that this method works in an actual iPhone and not on the simulator.
But i won't have an iPhone until Aug 9th....


All i am getting in the simulator is something like : "fe80::21e: 52ff:fec6:b7401.618407e-303n1"

I am wondering if anyone can confirm the method works (ie, returns an actual ip address) on an actual iPhone for me....

The code:

- (NSString*) getNetAddr {
char iphone_ip[255];
strcpy(iphone_ip,"127.0.0.1"); // if everything fails
NSHost *myhost =[NSHost currentHost];
//NSHost *myhost = [[NSHost alloc] init];
if (myhost)
{
NSLog(@"myhost exits");
NSString *ad = [myhost address];
if (ad)
strcpy(iphone_ip, [ad cStringUsingEncoding: NSISOLatin1StringEncoding]);
}


 return [NSString stringWithFormat:@"%s", iphone_ip];
}

Thank you in advance...

James

_______________________________________________

Cocoa-dev mailing list (email@hidden)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden
_______________________________________________

Cocoa-dev mailing list (email@hidden)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden

_______________________________________________

Cocoa-dev mailing list (email@hidden)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden


  • Prev by Date: Re: [iPhone] UITableView cell display bugs ?
  • Next by Date: Re: [iPhone] UITableView cell display bugs ?
  • Previous by thread: Re: [iPhone] get iPhone's IP address...
  • Next by thread: [iPhone] UITableView cell display bugs ?
  • Index(es):
    • Date
    • Thread