我有以下代码在钥匙串中创建钥匙串项目:
NSMutableDictionary* dict = [NSMutableDictionary dictionary]; [dict setObject: (__bridge id) kSecClassGenericPassword forKey: (__bridge id) kSecClass]; [dict setObject: MYKEY forKey: (__bridge id) kSecAttrService]; [dict setObject: @"0" forKey: (__bridge id) kSecValueData]; SecItemAdd ((__bridge CFDictionaryRef) dict,NULL);
哪个工作正常.如果我想更改此项,是否有人可以为SecItemUpdate提供准确的语法?
更新:具有以下内容:
NSMutableDictionary *query = [NSMutableDictionary dictionary]; NSMutableDictionary *attributesToUpdate = [NSMutableDictionary dictionary]; [query setObject: (__bridge id) kSecClassGenericPassword forKey: (__bridge id) kSecClass]; [query setObject: MYKEY forKey: (__bridge id) kSecAttrService]; [query setObject: (id) kcfBooleanTrue forKey: (__bridge id) kSecReturnData]; NSString *numberOfBalloonsString = [NSString stringWithFormat:@"%d",numberOfBalloonsUsed]; NSData *numberOfBalloonsData = [numberOfBalloonsString dataUsingEncoding:NSUTF8StringEncoding]; [attributesToUpdate setObject: numberOfBalloonsData forKey:(__bridge id)kSecValueData]; OSStatus error = SecItemUpdate ((__bridge CFDictionaryRef) query,(__bridge CFDictionaryRef) attributesToUpdate); NSLog(@"Error #: %ld",error);
One or more parameters passed to the function were not valid.