Try:
CFUUIDRef udid = CFUUIDCreate(NULL); NSString *udidString = (NSString *) CFUUIDCreateString(NULL, udid);
UPDATE:
Starting with iOS 6, there is an easier way to generate UUIDs . And, as usual, there are several ways to do this:
Create a UUID string:
NSString *uuid = [[NSUUID UUID] UUIDString];
Create UUID:
[[NSUUID UUID]; // which is same as.. [[NSUUID] alloc] init];
Creates an object of type NSConcreteUUID and can be easily added to NSString and looks like this: BE5BA3D0-971C-4418-9ECF-E2D1ABCB66BE
NOTE from the documentation:
Note. The NSUUID class is not a free bridge with CoreFoundations CFUUIDRef. Use UUID strings to convert between CFUUID and NSUUID, if necessary. Two NSUUIDs cannot be matched by pointer value (like CFUUIDRef); use isEqual: to compare two instances of NSUUID.
Raptor Jan 16 '13 at 6:21 2013-01-16 06:21
source share