-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 ...
随机推荐
- ERS-2卫星
ERS-2卫星是欧洲空间局的第二颗资源遥感卫星,携带有雷达测高仪.综合孔径雷达等多种科学仪器,是一颗多任务.多学科的科学考察卫星.[1] ERS-1 ERS-2 欧空局分别于1991年和1995年发射 ...
- Oracle笔记 七、PL/SQL 异常处理
--异常处理 declare sNum number := 0; begin sNum := 5 / sNum; dbms_output.put_line(sNum); exception when ...
- 搭建Android手机系统开发环境(转)
Android作为近来表现十分强劲的手机操作系统,越来越受到开发人员的青睐,本篇文章将带领大家从零开始打造属于自己的开发环境. 一.JDK下载安装 JDK全称是Java Development Kit ...
- linux 下安装 搭建 svn服务器
1.下载svn http://subversion.apache.org/download 下载完成后解压,执行 ./configure --prefix=/usr/svn 提示 configure: ...
- sql关联excel查询
select * from 表名 where 字段名 in (SELECT excel列名 FROM OpenDataSource( 'Microsoft.Jet.OLEDB.4.0','Data S ...
- Ubuntu 14.04 – How to install xrdp in Ubuntu 14.04
http://c-nergy.be/blog/?p=5305 Hello World, Ubuntu 14.04 has been released on April 17th 2014 and we ...
- 转 网络IO模型:同步IO和异步IO,阻塞IO和非阻塞IO
此文章为转载,如有侵权,请联系本人.转载出处,http://blog.chinaunix.net/uid-28458801-id-4464639.html 同步(synchronous) IO和异步( ...
- aspx页面中用Input 标签实现上传图片功能
实现上传图片功能需单独的建立一个aspx页面, 其中前台页面需要注意两点: a)实现上传功能的input的type="file" b)设置请求报文头为 enctype=" ...
- SQL Server编程(04)基本语法
一.定义变量 --简单赋值 declare @a int set @a=5 print @a --使用select语句赋值 declare @user1 nvarchar(50) select @ ...
- Java通过Executors提供四种线程池
http://cuisuqiang.iteye.com/blog/2019372 Java通过Executors提供四种线程池,分别为:newCachedThreadPool创建一个可缓存线程池,如果 ...