<Help>Getting iPhone id

Discussion in 'iPhone/iPad Programming' started by Moon013, Jul 14, 2008.

  1. macrumors newbie

    Joined:
    Jul 14, 2008
    #1
    Hi,
    Currently I am trying to do a application that will ask if the user wanted to send his iPhone id to a server. If he want he will click a button, and it will lead to a function that will get his iPhone id, and then send it to a server.

    I am not sure if this code gets the iPhone id:

    NSString* deviceName;
    deviceName = [[[UIDevice currentDevice] name] copy];

    I could not test it currently as there are still some missing stuff.

    In addition, I have absolute no idea how can i get the user location, not the ones with coordinates, but with countries names..is it possible?
     
  2. macrumors 65816

    Sbrocket

    Joined:
    Jun 3, 2007
    Location:
    /dev/null
    #2
    If you're trying to store unique data based on the device it is uploaded from, you don't want to use the name property.

    [[UIDevice mainDevice] uniqueIdentifier] is what you want.
     
  3. thread starter macrumors newbie

    Joined:
    Jul 14, 2008
    #3
    Hey thanks for helping!

    You have written "[UIDevice mainDevice]", why do we use the method mainDevice and not currentDevice?


    I have a hard time finding the information regardlin UIDevice class, kind of unsure what it has and what i could provides...sorry about that...
     
  4. macrumors 65816

    Sbrocket

    Joined:
    Jun 3, 2007
    Location:
    /dev/null
    #4
    Methods have specific names. You can't just change them at will.

    +[UIDevice mainDevice] (the + meaning its a class method) is how you access the singleton UIDevice object. Obviously there won't be more than one device, and mainDevice is how you access that one instance of UIDevice. As for "how you know" what the specific method, or property, or whatever is...that's why documentation exists.
     
  5. thread starter macrumors newbie

    Joined:
    Jul 14, 2008
    #5
    Thanks for the help :)
     
  6. macrumors newbie

    Joined:
    May 15, 2008
    #6
    Hey but i m getting error like "UIDevice may not support to main Device" so wt should i write man???
     
  7. macrumors 6502a

    Joined:
    Oct 24, 2008
    Location:
    Cambridge
    #7

Share This Page