Created
December 20, 2011 11:51
-
-
Save Abizern/1501325 to your computer and use it in GitHub Desktop.
A method that returns a UUID in an ARC environment.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
- (NSString *)uuidString { | |
// Returns a UUID | |
CFUUIDRef uuid = CFUUIDCreate(kCFAllocatorDefault); | |
NSString *uuidStr = (__bridge_transfer NSString *)CFUUIDCreateString(kCFAllocatorDefault, uuid); | |
CFRelease(uuid); | |
return uuidStr; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
This is a snippet that returns a UUID in an ARC compatible way.
This implementation is a method that you can drop into a class - if you like you can rewrite it as a class method in an NSString category
For methods that only require uniqueness across a network, eg, filenames for dynamically created resources in an app, - something simpler like
[[NSProcessInfo processInfo] globallyUniqueString]
might suit.