存储密码这类敏感类会用UICKeyChainStore
1.pod 导入UICKeyChainStore库
2.导入 Security.framework库
存数据:
UICKeyChainStore *keychainStore=[UICKeyChainStore keyChainStoreWithService:@"demo"];
keychainStore[@"password"] = @"123444";
或者[keychainStore setData:@”NSData类型的“ forKey:@"password"];
取数据:
UICKeyChainStore *keychainStore1 = [UICKeyChainStore keyChainStoreWithService:@"demo"];//要跟保存时保持一致
NSString *_passWordStr = [keychainStore1 stringForKey:@"password"];//要跟保存时保持一致
或者:NSData *data = [keychain dataForKey:@"password"];