Become a MacRumors Supporter for $50/year with no ads, ability to filter front page stories, and private forums.

Moon013

macrumors newbie
Original poster
Jul 14, 2008
23
0
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?
 

Sbrocket

macrumors 65816
Jun 3, 2007
1,250
0
/dev/null
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.
 

Moon013

macrumors newbie
Original poster
Jul 14, 2008
23
0
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...
 

Sbrocket

macrumors 65816
Jun 3, 2007
1,250
0
/dev/null
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...

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.
 
Register on MacRumors! This sidebar will go away, and you'll see fewer ads.