Chetan
Chetan

Reputation: 47981

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 a Mac?

Upvotes: 2

Views: 4175

Answers (3)

colinm
colinm

Reputation: 4288

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.

Upvotes: 2

user23743
user23743

Reputation:

[[NSProcessInfo processInfo] globallyUniqueString];

Upvotes: 0

diederikh
diederikh

Reputation: 25271

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

Upvotes: 3

Related Questions