IOS keyChain (simple use of key string), ioskeychain
In development, we usually need to save some values for a long time, such as the user's account and password. It is especially important to ensure data security for data with high privacy. KeyChain in ios is a good choice.
First, go to the developer website (https://developer.apple.com/library/ios/navigation/) to download a sample project called GenericKeychain.
We only need
Copy "KeychainItemWrapper. h" and "KeychainItemWrapper. m" to our project and import Security. framework
You also need to disable ARC for this class:
Buliding phase find the corresponding file-fno-objc-arc
The basic usage code is as follows:
KeychainItemWrapper * wra; @ implementation ViewController-(void) viewDidLoad {[super viewDidLoad]; wra = [[KeychainItemWrapper alloc] handler: @ "password" accessGroup: @ "wjl.com"]; -(IBAction) getOb :( id) sender {/***** @ param @ "account % @" * @ param id must be Security. secitem. */NSLog (@ "account =%@", [wra objectForKey :( id) kSecAttrAccount]);}-(IBAction) clear :( id) defined in h) sender {[wra resetKeychainItem]; // clear settings}-(IBAction) set :( id) sender {[wra setObject: @ "wjl123" forKey :( id) kSecAttrAccount];}