-25299 reason: 'Couldn't add the Keychain Item.'
今天在用苹果官方demo 提供的KeychainItemWrapper类时遇到-25299 reason: 'Couldn't add the Keychain Item.'错误,再4s上可以正常运行,但6上却崩溃
崩溃位置
result = SecItemAdd((CFDictionaryRef)[self dictionaryToSecItemFormat:keychainItemData], NULL);
NSAssert( result == noErr, @"Couldn't add the Keychain Item." );
我调用的方法
CFUUIDRef uuidRef = CFUUIDCreate(kCFAllocatorDefault);
strUUID = (NSString *)CFBridgingRelease(CFUUIDCreateString (kCFAllocatorDefault,uuidRef));
[keychainItem setObject:strUUID forKey:(__bridge id)kSecValueData];
通过看国外的文章知道了方法(http://stackoverflow.com/questions/4309110/error-saving-in-the-keychain-with-iphone-sdk)
修改方法: 加上下面这行代码就能正常运行
[keychainItem setObject:@"MY_APP_CREDENTIALS" forKey:(id)kSecAttrService];
最后修改成代码为:
[keychainItem setObject:@"MY_APP_CREDENTIALS" forKey:(id)kSecAttrService];
CFUUIDRef uuidRef = CFUUIDCreate(kCFAllocatorDefault);
strUUID = (NSString *)CFBridgingRelease(CFUUIDCreateString (kCFAllocatorDefault,uuidRef));
[keychainItem setObject:strUUID forKey:(__bridge id)kSecValueData];
原因:
KeyChain内部以kSecAttrAccount 与kSecAttrService作为唯一钥匙串标识,两个都必须设置才行;
-25299 reason: 'Couldn't add the Keychain Item.'的更多相关文章
- iOS开发—— Couldn't add the Keychain Item
报错:*** Terminating app due to uncaught exception 'NSInternalInconsistencyException', reason: 'Couldn ...
- [转]NopCommerce How to add a menu item into the administration area from a plugin
本文转自:http://docs.nopcommerce.com/display/nc/How+to+code+my+own+shipping+rate+computation+method Go t ...
- 第十八篇、keychain保存UUID(保持唯一性,应用卸载,下载安装也不变)和获取IP地址
.h #import <Foundation/Foundation.h> #import <Security/Security.h> /**使用**/ //-(void) se ...
- (绝对有用)iOS获取UUID,并使用keychain存储
原文链接 http://blog.sina.com.cn/s/blog_5971cdd00102vqgy.html UDID被弃用,使用UUID来作为设备的唯一标识.获取到UUID后,如果用NSUse ...
- IOS - UDID IDFA IDFV MAC keychain
在开发过程中,我们经常会被要求获取每个设备的唯一标示,以便后台做相应的处理.我们来看看有哪些方法来获取设备的唯一标示,然后再分析下这些方法的利弊. 具体可以分为如下几种: UDID IDFA IDFV ...
- iOS之数据安全
一.数据安全 术语----- 密钥:密钥是一种参数, 它是在明文转换为密文, 或将密文转换为明文的算法中输入的参数. 密钥分为对称密钥和非对称密钥(也可以根据用途来分为加密密钥和解密密钥) 明文:没有 ...
- xcode编译错误总结
No architectures to compile for(ONLY_ACTIVE_ARCH=YES 这种错误 修改building settings下 Build Active Archi ...
- Add an Item to the Navigation Control 将项目添加到导航控件
In this lesson, you will learn how to add an item to the navigation control. For this purpose, the N ...
- iOS keyChain 的使用
详细资料,请参看苹果官方文档Keychain Services Reference . ios中的keychain,用于保存用户的机密信息,对keychain的操作有4种,就是 增,删,改,查: Se ...
随机推荐
- centos系统自动化安装研究
https://rhinstaller.github.io/anaconda/intro.html https://github.com/rhinstaller/pykickstart/blob/ma ...
- jQuery源码的几篇文章
http://lingyu.wang/#/post/2014/5/8/read-jq-src-1 http://lingyu.wang/#/post/2014/5/10/read-jq-src-2 h ...
- RPC通信(Windows版、Android版)
1.RPC通信模型 2.调用截图 服务器端 PC客户端: Android客户端: 3.remotetea jrpcgen.jar:生成Java源文件 oncrpc.jar:框架通信调用 portmap ...
- javaSE第十五天
第十五天 117 1. 对象数组(掌握) 117 (1)定义: 117 (2)对象数组的内存图解 117 (3)案例: 117 2. 集合(Collection)(掌握) ...
- iOS NSString中字符串的删除,替换
- ububtu 14.04 问题集合
作者:jostree 转载请注明出处 http://www.cnblogs.com/jostree/p/4168168.html 1.Chromium 中的flash插件问题: sudo apt-ge ...
- mariadb数据库备份学习笔记
备份类型: 完全备份 部分备份:仅备份其中的一张表或多张表 增量备份:仅备份从上次完全备份或增量备份之后变化的数据部分 热备份:在线备份,读写操作不受影响 温备份:在线备份,读操作可继续进行,但写操作 ...
- devexpress 数据导入(gridcontrol 导出 csv)
// 1.gridcontrol 导出 csv: DataTable dtbNew = new DataTable(); dtbNew.Columns.Add().GetType()); dtbNew ...
- Autofac的注入和web.config配合
public static void BuildMvcContainer() { var builder = new ContainerBuilder(); var assemblys = AppDo ...
- python 类属性和实例属性
class AAA(): aaa = 10 # 情形1 obj1 = AAA() obj2 = AAA() print obj1.aaa, obj2.aaa, AAA.aaa # 情形2 obj1.a ...