Skip to content

Instantly share code, notes, and snippets.

@oliverbarreto
Forked from sendoa/gist:4135566
Created December 8, 2013 09:30
Show Gist options
  • Save oliverbarreto/7855137 to your computer and use it in GitHub Desktop.
Save oliverbarreto/7855137 to your computer and use it in GitHub Desktop.
//http://mobiledevelopertips.com/core-services/create-universally-unique-identifier-uuid-the-ios-6-way.html
//The class NSUUID implements RFC 4122 creating values that are 128 bits long and guaranteed to be unique across space and time by using a unique value on the device as well as a value representing the elapsed time since October 15, 1582 at 00:00:00.
// iOS 6
NSUUID *uuid = [NSUUID UUID];
NSLog(@"UUID: %@", [uuid UUIDString]);
// Output: UUID: A84AFC3C-B3A7-31C7-B3E9-234AF423C6B1
// iOS < 6
CFUUIDRef uuid = CFUUIDCreate(NULL);
CFStringRef identifier = CFUUIDCreateString(NULL, uuid);
CFRelease(uuid);
NSString *uuidString = CFBridgingRelease(identifier);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment