更新唯一标示符
来源:互联网 发布:如何优化供应商 编辑:程序博客网 时间:2024/05/20 02:24
NSMutableDictionary *dictForQuery = [[NSMutableDictionary alloc] init]; [dictForQuery setValue:(id)kSecClassGenericPassword forKey:(id)kSecClass]; NSData *keychainItemID = [NSData dataWithBytes:kKeychainUDIDItemIdentifier length:strlen(kKeychainUDIDItemIdentifier)]; [dictForQuery setValue:keychainItemID forKey:(id)kSecAttrGeneric]; [dictForQuery setValue:(id)kCFBooleanTrue forKey:(id)kSecMatchCaseInsensitive]; [dictForQuery setValue:(id)kSecMatchLimitOne forKey:(id)kSecMatchLimit]; [dictForQuery setValue:(id)kCFBooleanTrue forKey:(id)kSecReturnAttributes]; NSDictionary *queryResult = nil; SecItemCopyMatching((CFDictionaryRef)dictForQuery, (CFTypeRef*)&queryResult); if (queryResult) { NSMutableDictionary *dictForUpdate = [[NSMutableDictionary alloc] init]; [dictForUpdate setValue:[NSString stringWithUTF8String:kKeychainUDIDItemIdentifier] forKey:kSecAttrDescription]; [dictForUpdate setValue:keychainItemID forKey:(id)kSecAttrGeneric]; const char *udidStr = [newUDID UTF8String]; NSData *keyChainItemValue = [NSData dataWithBytes:udidStr length:strlen(udidStr)]; [dictForUpdate setValue:keyChainItemValue forKey:(id)kSecValueData]; OSStatus updateErr = noErr; // First we need the attributes from the Keychain. NSMutableDictionary *updateItem = [NSMutableDictionary dictionaryWithDictionary:queryResult]; // Second we need to add the appropriate search key/values. // set kSecClass is Very important [updateItem setObject:(id)kSecClassGenericPassword forKey:(id)kSecClass]; updateErr = SecItemUpdate((CFDictionaryRef)updateItem, (CFDictionaryRef)dictForUpdate); if (updateErr != errSecSuccess) { NSLog(@"Update KeyChain Item Error!!! Error Code:%d", (int)updateErr); [dictForQuery release]; [dictForUpdate release]; return NO; } else { NSLog(@"Update KeyChain Item Success!!!"); [dictForQuery release]; [dictForUpdate release]; return YES; } } [dictForQuery release]; return NO;
0 0
- 更新唯一标示符
- IOS 唯一标示符
- 唯一标示符
- 设备唯一标示符
- ios唯一标示符
- iOS唯一标示符引导
- iOS唯一标示符引导
- iOS唯一标示符引导
- iOS唯一标示符引导
- iOS唯一标示符引导
- IOS设备唯一标示符
- iOS唯一标示符引导
- iOS唯一标示符引导
- iOS唯一标示符引导
- iOS唯一标示符引导
- iOS唯一标示符引导
- iOS唯一标示符引导
- 获取手机唯一标示符
- SPEC文件详解
- Fragment详解(2)
- SQLite Page Cache之并发控制
- Python 文本挖掘:使用gensim进行文本相似度计算
- 批处理定时备份oracle的脚本
- 更新唯一标示符
- 近 100 个 Linux 常用命令大全
- 工作备忘-位移枚举
- 剑指Offer--011-数值的整数次方
- C++类型强制转换
- Android 集成支付宝_快速测试公司账号的收款功能
- 亚马逊或投资HERE 力图扼杀谷歌快递梦想
- JSP 生命周期
- java.util.timer每天 在固定时间