tags:

views:

8095

answers:

5

I want to be able to create a GUID/UUID on the iPhone but I can't see any way to do it.

The intention is to be able to create keys for distributed data, that are all unique. Do I need some third-party code or is there a built in way to do this in the SDK?

I have tried Googling it, but I could find anything.

+3  A: 

If you want a unique identifier for the particular iPhone you're running on, you can run

NSString *uniqueIdentifier = [[UIDevice currentDevice] uniqueIdentifier];

You can then use that as a replacement for a MAC address in any of the standard GUID/UUID generation algorithms.

Adam Rosenfield
+20  A: 

Reviewing the Apple Developer documentation I found the CFUUID object is available on the iPhone OS 2.0 and later.

Henk
that's exactly what I was after, thanks
rustyshelf
I could really use an example, like below...
bentford
+36  A: 
[[UIDevice currentDevice] uniqueIdentifier]

Returns the Unique ID of your iPhone.

If you need to create several UUID, just use this method:

+ (NSString *)GetUUID
{
  CFUUIDRef theUUID = CFUUIDCreate(NULL);
  CFStringRef string = CFUUIDCreateString(NULL, theUUID);
  CFRelease(theUUID);
  return [(NSString *)string autorelease];
}
Stephan Burlot
+10  A: 

The simplest technique is to use NSString *uuid = [[NSProcessInfo processInfo] globallyUniqueString]. See the NSProcessInfo class reference.

Ryan McCuaig
A: 

Hi, I am looking for a way to extract my iPhone (OS v3.0) UUID without using iTunes. I tried "UUID Revealer" from Cydia Store but that is not working on my system. I could SSH with WinSCP and I have a Terminal Program Installed. Any chances using one of those tools (or another one) to bring to light my UUID? Thanks

Eddie
hi Eddie - bit late now, but you should ask a question rather than adding an answer to someone elses question.
Toby Allen