本文介绍了在钥匙串中存储电子邮件是不可能的(KeychainItemWrapper)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用上提供的ARCified版KeychainItemWrapper,我无法得到它存储电子邮件和密码。

I'm using the ARCified version of KeychainItemWrapper available at github, and I can't get it to store both email and password.

KeychainItemWrapper *keychainItem = [[KeychainItemWrapper alloc] initWithIdentifier:@"myApp" accessGroup:@"MY_APP.com.yourcompany.GenericKeychainSuite"];
    [keychainItem setObject:[self.email dataUsingEncoding:NSUTF8StringEncoding] forKey:(__bridge id)kSecAttrAccount];
    [keychainItem setObject:self.password forKey:(__bridge id)kSecValueData];    

只要我存储了一封没有标志的电子邮件,我的工作就完美了(@)它。否则,我收到错误

I works perfectly as long as I store an email... that don't have an at sign (@) it. Otherwise, I get the error

*** Assertion failure in -[KeychainItemWrapper writeToKeychain]
*** Terminating app due to uncaught exception 'NSInternalInconsistencyException', reason: 'Couldn't add the Keychain Item.'

其中来自那些行

result = SecItemAdd((__bridge CFDictionaryRef)[self dictionaryToSecItemFormat:keychainItemData], NULL);
NSAssert( result == noErr, @"Couldn't add the Keychain Item." );

你对这里可能出现的问题有什么看法吗?

Do you have any idea about what can be going wrong here ?

谢谢

推荐答案

好吧,我刚刚根据该页面上的建议找到答案,即添加

Well, I just found the answer following the advice on that page iOS KeychainItemWrapper not updating, which is to add

[keychainWrapper setObject:@"Myappstring" forKey: (id)kSecAttrService];

这篇关于在钥匙串中存储电子邮件是不可能的(KeychainItemWrapper)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

10-26 16:52