About ios KeychainItemWrapper store username/password other than object

倖福魔咒の 提交于 2019-12-12 23:23:03

问题


I know save username/password use KeychainItemWrapper class method below, but I want an additional [ipTF text] in KeychainItemWrapper. How to do it?

KeychainItemWrapper *keychainItem = [[KeychainItemWrapper alloc] initWithIdentifier:@"Login" accessGroup:nil];

[keychainItem setObject:[useridTF text] forKey:(__bridge id)(kSecAttrAccount)];
[keychainItem setObject:[passTF text] forKey:(__bridge id)(kSecValueData)];
[keychainItem setObject:[ipTF text] forKey:@"ip"];//not success!

回答1:


I don't think it's possible to create arbitrary key/value pairs in the key chain items.

Keychain Services Reference

This section lists all the keys that specify keychain item attributes. The description of each item indicates what the possible values are for that key.

The list of possible keys is determined by the kSecClass. You can find the list of options and their descriptions in the Keychain Services References under the following quote describing how the key set is determined.

Key constant used to set the item class value in a search dictionary.

CFTypeRef kSecClass;
Constants

kSecClass
Dictionary key whose value is the item's class code. Possible values for this key are listed in “Item Class Value Constants.”



回答2:


Specify a new key and store the value there



来源:https://stackoverflow.com/questions/15765560/about-ios-keychainitemwrapper-store-username-password-other-than-object

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!