Created
April 23, 2012 08:27
-
-
Save onevcat/2469512 to your computer and use it in GitHub Desktop.
UUID
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| - (NSString *)createUUID | |
| { | |
| // Create universally unique identifier (object) | |
| CFUUIDRef uuidObject = CFUUIDCreate(kCFAllocatorDefault); | |
| // Get the string representation of CFUUID object. | |
| NSString *uuidStr = [(NSString *)CFUUIDCreateString(kCFAllocatorDefault, uuidObject) autorelease]; | |
| // If needed, here is how to get a representation in bytes, returned as a structure | |
| // typedef struct { | |
| // UInt8 byte0; | |
| // UInt8 byte1; | |
| // ... | |
| // UInt8 byte15; | |
| // } CFUUIDBytes; | |
| CFUUIDBytes bytes = CFUUIDGetUUIDBytes(uuidObject); | |
| CFRelease(uuidObject); | |
| return uuidStr; | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment