加入收藏 | 设为首页 | 会员中心 | 我要投稿 李大同 (https://www.lidatong.com.cn/)- 科技、建站、经验、云计算、5G、大数据,站长网!
当前位置: 首页 > 百科 > 正文

iphone – 用KeyChainItemWrapper存储KeyChain中的键

发布时间:2020-12-15 01:53:36 所属栏目:百科 来源:网络整理
导读:我使用的是KeyChainItemWrapper类,由Apple的Sample Code提供,将认证令牌保存到钥匙串。 KeychainItemWrapper *keychain = [[KeychainItemWrapper alloc] initWithIdentifier"JetTaxiApp_AuthToken" accessGroup:nil]; 但是当我尝试将该值设置为keychain时
我使用的是KeyChainItemWrapper类,由Apple的Sample Code提供,将认证令牌保存到钥匙串。

KeychainItemWrapper *keychain = [[KeychainItemWrapper alloc] initWithIdentifier"JetTaxiApp_AuthToken" accessGroup:nil];

但是当我尝试将该值设置为keychain时,会出现一个奇怪的异常

[_authenticationTokenKeychain setObject:authenticationToken forKey: @"auth_token"];

Terminating app due to uncaught exception
‘NSInternalInconsistencyException’,reason: ‘Couldn’t add the Keychain
Item.’

钥匙扣尚不存在(在此通话的时刻)
什么可能导致此异常?

解决方法

你需要使用标准键,所以这里你的@“auth_token”是不正确的。

The keys that can be used for this purpose and the possible values for each key are listed in the “Keychain Services Constants” section.

源,有效常数列表:Keychain Services Reference

例如,您可以使用:

[_authenticationTokenKeychain setObject:authenticationToken forKey: (__bridge NSString *)kSecValueData];

(编辑:李大同)

【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!

    推荐文章
      热点阅读