开发者

Generating a computer-specific UUID in Xcode

开发者 https://www.devze.com 2022-12-15 17:19 出处:网络
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:

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

精彩评论

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