使用钥匙串
KeychainItemWrapper
#pragma mark - keychain读取
- (IBAction)read {
KeychainItemWrapper *wrapper = [[KeychainItemWrapper alloc] initWithIdentifier:@"Username"accessGroup:nil];
NSLog(@"pwd = %@,account = %@",[wrapper objectForKey:(__bridge id)kSecValueData],[wrapper objectForKey:(__bridge id)kSecAttrAccount]);
}
#pragma mark - keychain存储
- (void)save {
KeychainItemWrapper *wrapper = [[KeychainItemWrapper alloc]initWithIdentifier:@"Username"accessGroup:nil];
//保存帐号
[wrapper setObject:@"ly" forKey:(__bridge id)kSecAttrAccount];
//保存密码
[wrapper setObject:@"123456" forKey:(__bridge id)kSecValueData];
[wrapper setObject:@"aaaaaa" forKey:(__bridge id)kSecAttrTokenID];
}