问题
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;ConstantskSecClassDictionary 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