UUID’s are string values separated by hyphens, for example, here is how a UUID may look: 13222F23-C76A-7781-0C12-0293E3B34398.
The method below creates a UUID and returns a string representation of the same:
Create UUID
- (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; }
0 comments:
Post a Comment
Note: Only a member of this blog may post a comment.