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);
我收到错误代码-50 =
解决方法 SecItemUpdate非常详细.One or more parameters passed to the function were not valID.
SecItemUpdate的查询参数记录为查询(在其他函数中使用)以及模糊语句:“指定要更改其值的项目”.这似乎意味着您必须在此字典中包含您想要更改的现有属性值,但我认为您不会这样做.我发现您可以使用相同的查询来获取要更新的项目的属性.
attributes参数应该是SecItemcopyMatching的结果,其中包含kSecValueData键和添加的值以及任何属性已更改.
总结以上是内存溢出为你收集整理的ios – 在Keychain服务中使用SecItemUpdate全部内容,希望文章能够帮你解决ios – 在Keychain服务中使用SecItemUpdate所遇到的程序开发问题。
如果觉得内存溢出网站内容还不错,欢迎将内存溢出网站推荐给程序员好友。
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)