How do I generate a UUID that will uniquely identify a computer using Xcode / Objective-C? Windows has UuidCreateSequential()
, what can I use on a Mac?
views:
297answers:
3
+2
A:
Try this:
CFUUIDRef UUID = CFUUIDCreate(kCFAllocatorDefault);
CFStringRef UUIDString = CFUUIDCreateString(kCFAllocatorDefault,UUID);
// UUIDString is the CFStringRef (== NSString *) that contains the UUID.
// Cleanup
CFRelease(UUID);
CFRelease(UUIDString);
Diederik Hoogenboom
2009-12-31 10:55:15
Will this be unique for a computer across the world?
Chetan
2010-01-01 01:16:49
And is it Mac-specific, or will the Windows version (`UuidCreateSequential()`) give the same result?
Chetan
2010-01-01 01:17:33
According to this: http://developer.apple.com/mac/library/documentation/CoreFoundation/Reference/CFUUIDRef/Reference/reference.html, the UUID is unique across time and space. I need it to be the same across time because I want to be able to use it at any time to uniquely identify a computer. How do I do this?
Chetan
2010-01-01 01:23:14
You could use the MAC address. See GetPrimaryMACAddress sample code in XCode Developer Documentation.
Diederik Hoogenboom
2010-01-01 13:45:28
globallyUniqueString is guarantied to be unique across the network (according to the docs). globallyUniqueString also doesn't guarantee the length or nature of the returned string, while UUID's have a prescribed format.
Diederik Hoogenboom
2009-12-31 11:11:47