Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Whats this difference between [[NSUUID new] UUIDString] & CFUUIDRef

What's the difference between creating a UUID by these two implementations give below?

1)

CFUUIDRef cfuuid = CFUUIDCreate(kCFAllocatorDefault);
NSString *udidString = (NSString*)CFBridgingRelease(CFUUIDCreateString(kCFAllocatorDefault, cfuuid));
NSString *guid = [[NSUUID new] UUIDString];`

Which one is more reliable? I'm working on an app for iOS 8+.

like image 522
Vicky Dhas Avatar asked Oct 24 '25 18:10

Vicky Dhas


1 Answers

You can find details on NSHipster's uuid-udid-unique-identifier post.

In the interest of not posting 'link only' answer here are excerpts form the same article:

NSUUID was added to Foundation in iOS 6 as a way to easily create UUIDs.

If your app targets iOS 5 or earlier, however, you have to settle for Core Foundation functions on CFUUIDRef

To sum up, although both return a valid UUID, go ahead and use NSUUID as its easier.

like image 106
Swapnil Luktuke Avatar answered Oct 27 '25 12:10

Swapnil Luktuke