A simple Objective-C wrapper for CFUUID.
© 2012 Dan Wineman. Published under the MIT License.
A DWUUID is immutable and has the same uniqueness guarantees as CFUUID (Universally Unique Identifier, a 128-bit value generated using the computer's Ethernet hardware address and a timestamp). It conforms to NSCoding and NSCopying, and it implements -hash
and -isEqual:
, so it can be used as an NSDictionary key.
DWUUID.m
may be compiled with or without ARC.
#import "DWUUID.h"
DWUUID *uuid = [[DWUUID alloc] init];
// Get the UUID as a string
NSString *uuidString = [uuid stringValue];
// Get the UUID as a 16-byte CFUUIDBytes struct
CFUUIDBytes uuidBytes = [uuid bytes];
// Easy logging
NSLog(@"My UUID is: %@", uuid);
// Clean up (if not using ARC)
[uuid release];