Apple has banned UUID applications since January 1. So we need to replace it with some methods. Below I will replace the uuid with the keychain access.
For the keychain application, Apple provides an example program named generickeychain. Here: Example.
1. Import the Security. Framework file to the database and import the keychainitemwrapper. h and keychainitemwrapper. M files to the project, and reference the header file: # import "keychainitemwrapper. H"
2. code example:
NSString *str =nil; KeychainItemWrapper *keychainItem = [[KeychainItemWrapper alloc] initWithIdentifier:@"UUID" accessGroup:@"com.xxx.xxx"]; NSString *uuidStr = [keychainItem objectForKey:(id)kSecValueData]; if (uuidStr.length == 0) { NSString *myUUIDStr = [[[UIDevice currentDevice] identifierForVendor] UUIDString]; [keychainItem setObject:myUUIDStr forKey:(id)kSecValueData]; str = myUUIDStr; } else{ str = [keychainItem objectForKey:(id)kSecValueData]; } NSLog(@"======%@",str); return str;
The imported security. Framework is because the keychainitemwrapper file only encapsulates security and is more conducive to our calls.