Results 1 to 2 of 2
  1. #1


    Member Since
    Apr 24, 2010
    Location
    Ireland
    Posts
    5
    Specs:
    Dual 1GHz G4 OSX10.4.11
    NSString containing IvP4 of machine
    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

  2. #2


    Member Since
    Apr 24, 2010
    Location
    Ireland
    Posts
    5
    Specs:
    Dual 1GHz G4 OSX10.4.11
    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

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Similar Threads

  1. From Parallels Desktop virtual machine, to new physical machine?
    By CovertBandit in forum Running Windows (or anything else) on your Mac
    Replies: 1
    Last Post: 08-02-2012, 10:27 AM
  2. Replies: 0
    Last Post: 06-02-2010, 01:43 PM
  3. Which of these two ways are the best NSString Initializer ?
    By Bracer in forum OS X - Development and Darwin
    Replies: 3
    Last Post: 10-08-2009, 04:10 PM
  4. Can Time Machine use an external drive connected to a Tiger machine?
    By dwhewlings in forum OS X - Operating System
    Replies: 0
    Last Post: 02-01-2009, 09:12 PM
  5. Time Machine backup restore on/to a different machine?
    By scarredtaka in forum OS X - Operating System
    Replies: 3
    Last Post: 01-10-2008, 04:35 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •