IOS development USES KeychainItemWrapper to persist user names and passwords
- 2020-05-13 03:21:24
- OfStack
First download from the official website
KeychainItemWrapper.h
KeychainItemWrapper.m
Import these two files into the project. However, this file is released manually, so you need to do some processing to use this file:
If you want to use the KeychainItemWrapper.h class, select this class in CompileSources and add -fno-objc-arc
Next, directly enter the code:
KeychainItemWrapper *keychain=[[KeychainItemWrapper alloc] initWithIdentifier:@"myKey" accessGroup:nil];//myKey The custom
// Save the data save 1 Even if the program is deleted The phone still keeps its key string Still can be keychain To obtain
// [keychain setObject:@"little Pig" forKey:(id)kSecAttrAccount];// Account name
//
// [keychain setObject:@"123456" forKey:(id)kSecValueData];// The account password
// from keychain Take out the account password
NSString *password = [keychain objectForKey:(id)kSecValueData];
NSLog(@"%@", password);
// Empty set
// [keychain resetKeychainItem];
The above is the site to give you about the development of IOS using KeychainItemWrapper persistent storage of user names and passwords all content, I hope you like.