开发者社区> 问答> 正文

iOS模拟器使用钥匙串不能写入值?报错

确认使用的是SecItem.h中定义的KEY, 声明如此

KeychainItemWrapper keychain = [[KeychainItemWrapper alloc] initWithIdentifier:@"MerchantAccountNumber"
                                         accessGroup:@"com.tr-gr.Merchant"];

[wrapper setObject:self.IDFV forKey:(__bridge id)kSecAttrDescription];

问题是:如果选用 iPhone retina(4-inch 64bit) 编译运行都OK, 但选用iPhone retina(3.5-inch) 或者 iPhone retina(4-inch) 编译通过, 运行时报错如下:

*** Assertion failure in -[KeychainItemWrapper writeToKeychain], /

KeychainItemWrapper.m:354
2014-02-18 09:59:39.364 Merchant[1517:a0b] *** Terminating app due to uncaught exception 'NSInternalInconsistencyException', reason: 'Couldn't add the Keychain Item.'


代码都一样的, 为何选择不同的模拟器设备, 运行就出错了呢? 大家有遇到过吗?

展开
收起
爱吃鱼的程序员 2020-06-22 12:50:30 774 0
1 条回答
写回答
取消 提交回答
  • https://developer.aliyun.com/profile/5yerqm5bn5yqg?spm=a2c6h.12873639.0.0.6eae304abcjaIB

    问题解决, KeyChain内部以kSecAttrAccount  与kSecAttrService作为唯一钥匙串标识,


    传送门  http://stackoverflow.com/questions/4891562/ios-keychain-services-only-specific-values-allowed-for-ksecattrgeneric-key

    2020-06-22 12:50:48
    赞同 展开评论 打赏
问答排行榜
最热
最新

相关电子书

更多
手淘iOS性能优化探索 立即下载
From Java/Android to Swift iOS 立即下载
深入剖析iOS性能优化 立即下载