每天写1000字每天写500字

ios - 钥匙串开发(keychain开发)

2016-11-01  本文已影响596人  AlexPei
设置中直接打开 Paste_Image.png Paste_Image.png

值得注意的是他的key值只能是系统里的,不能我们自定义,否则崩溃


#pragma mark - keychain读取
- (IBAction)keychainRead:(id)sender {
    
    KeychainItemWrapper *wrapper = [[KeychainItemWrapper alloc]initWithIdentifier:@"Username"accessGroup:nil];
    KLog(@"pwd = %@,account = %@",[wrapper objectForKey:(__bridge id)kSecValueData],[wrapper objectForKey:(__bridge id)kSecAttrAccount]);

}
#pragma mark - keychain存储
- (IBAction)clickJieM:(id)sender {
    
    KeychainItemWrapper *wrapper = [[KeychainItemWrapper alloc]initWithIdentifier:@"Username"accessGroup:nil];
    //保存帐号
    [wrapper setObject:@"张三" forKey:(__bridge id)kSecAttrAccount];
    //保存密码
    [wrapper setObject:@"212121" forKey:(__bridge id)kSecValueData];
}

上一篇下一篇

猜你喜欢

热点阅读