Created
April 13, 2014 06:26
-
-
Save ArchieGoodwin/10571582 to your computer and use it in GitHub Desktop.
UUID generate
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
f you are on OS X 10.8 or iOS 6 you can use the new NSUUID class to generate a string UUID, without having to go to Core Foundation: | |
NSString *uuidString = [[NSUUID UUID] UUIDString]; | |
// Generates: 7E60066C-C7F3-438A-95B1-DDE8634E1072 | |
But mostly, if you just want to generate a unique string for a file or directory name then you can use NSProcessInfo's globallyUniqueString method like: | |
NSString *uuidString = [[NSProcessInfo processInfo] globallyUniqueString]; | |
// generates 56341C6E-35A7-4C97-9C5E-7AC79673EAB2-539-000001F95B327819 | |
It's not a formal UUID, but it is unique for your network and your process and is a good choice for a lot of cases. |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment