开发者

Generating a computer-specific UUID in Xcode

How do I generate a UUID that will uniquely identify a computer using Xcode / Objective-C? Windows has UuidCreateSequential(), what can I use on开发者_StackOverflow中文版 a Mac?


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);  


You can read the system serial number or the hardware MAC addresses using IOKit.

Check out Apple Technical Note TN1103 ("Uniquely Identifying a Macintosh Computer") for sample code and more information.


[[NSProcessInfo processInfo] globallyUniqueString];
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜