New To Mac-Forums?

Welcome to our community! Join the discussion today by registering your FREE account. If you have any problems with the registration process, please contact us!

Get your questions answered by community gurus Advice and insight from world-class Apple enthusiasts Exclusive access to members-only contests, giveaways and deals

Join today!

 
Start a Discussion
 

Mac-Forums Brief

Subscribe to Mac-Forums Brief to receive special offers from Mac-Forums partners and sponsors

Join the conversation RSS
OS X - Development and Darwin Discussion and questions about development for Mac OS X.

NSString containing IvP4 of machine


Post Reply New Thread Subscribe

 
Thread Tools
chriseccles

 
Member Since: Apr 24, 2010
Location: Ireland
Posts: 5
chriseccles is on a distinguished road
Mac Specs: Dual 1GHz G4 OSX10.4.11

chriseccles is offline
Sorry to be a pain with noob questions, but does anyone know
a way of returning an NSString object containing the LAN IP address
of the machine the app is running on ? ?

Thanks

Chris
QUOTE Thanks
chriseccles

 
Member Since: Apr 24, 2010
Location: Ireland
Posts: 5
chriseccles is on a distinguished road
Mac Specs: Dual 1GHz G4 OSX10.4.11

chriseccles is offline
It seems to be a good day for solving my own problems !


After a couple of hours' fannying around, I found an easy way to
do this, although it may not be foolproof on every machine:

Use:

NSArray *mcAddresses = [NSHost addresses];
NSString *ipv4 = [mcAddresses objectAtIndex: 1];


The 0 index of the [NSHost addresses] array is always the ipv6 extended address.
The 1 index seems always to return the ipv4 address of the machine for
the current location setting in System Preferences > Network, which is what
most people will want, I guess.

Chris
QUOTE Thanks

Post Reply New Thread Subscribe


« Distributed Object (newbie problem) | How to define a new file association with a binary application (not a .App) ? »
Thread Tools

Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts
BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off
Forum Jump

Similar Threads
Thread
Thread Starter
Forum
Replies
Last Post
Using a hardrive with two computers, one that has time machine, and one that does not Troublew/macs93 Other Hardware and Peripherals 2 01-18-2010 08:59 PM
Time machine, space issues. Jonik OS X - Apps and Games 8 01-04-2010 03:46 PM
Writing to Time Machine Backups drive from Linux sworddude182 Running Windows (or anything else) on your Mac 4 12-12-2009 09:12 PM
Backing up - time machine versus third party software? Narcosnthesis OS X - Apps and Games 2 01-06-2009 02:50 PM
Parallels - can't copy from Windows XP virtual machine and paste to Mac Pro ithacalaw Running Windows (or anything else) on your Mac 5 10-22-2006 09:14 PM

All times are GMT -4. The time now is 02:07 AM.

Powered by vBulletin
Copyright ©2000 - 2014, Jelsoft Enterprises Ltd.
X

Welcome to Mac-Forums.com

Create your username to jump into the discussion!

New members like you have made this community the ultimate source for your Mac since 2003!


(4 digit year)

Already a member?