Creating UUIDs and UDIDs in iOS 7

I want to create a UUID, I have the code below that can create a UUID, how can I create a UDID with multiple providers of the same identifier in iOS7?

+ (NSString*) stringWithNewUUID { CFUUIDRef uuidObj = CFUUIDCreate(nil); NSString *newUUID = (NSString*)CFUUIDCreateString(nil, uuidObj); CFRelease(uuidObj); return newUUID; } 
+5
ios iphone ios7
09 Oct '13 at 6:41
source share
5 answers

I created a provider id and then saved it with keychain, which I save next time using KeychainWrapper keychainStringFromMatchingIdentifier:...

+4
Oct 11 '13 at 5:35 on
source share

The CFUUIDCreate function creates a version 4 UUID that is completely taken from a pseudo random number generator. There are no timestamps or MAC addresses in this type of UUID. (This refers to the less-used flavor of version 1). They are safe to use for almost all applications.

+6
Oct 09 '13 at 6:59
source share

This method returns random UUIDs in iOS 6 and above.

 [[UIDevice currentDevice]identifierForVendor] 
+5
Oct 09 '13 at 9:53 on
source share

The UUID obtained by the above code does not have a timestamp in it. This is just a line that looks something like this: E1D87006-7CD0-4E28-9768-624DA92F75D6

+2
09 Oct '13 at 6:50
source share

I followed Sandip Cade's answer and made the following code using PDKeychainBindings . This is the same as using NSUserDefaults, but it contains an identifier in the keychain that retains data even when the application is deleted.

 + (NSString *)uniqueVendor { PDKeychainBindings *keychain = [PDKeychainBindings sharedKeychainBindings]; NSString *uniqueIdentifier = [keychain objectForKey:kKeyVendor]; if (!uniqueIdentifier || !uniqueIdentifier.length) { NSUUID *udid = [[UIDevice currentDevice] identifierForVendor]; uniqueIdentifier = [udid UUIDString]; [keychain setObject:uniqueIdentifier forKey:kKeyVendor]; } return uniqueIdentifier; } 
0
Feb 26 '14 at 13:23
source share



All Articles