1

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!
pkamb
  • 33,281
  • 23
  • 160
  • 191
SimonKira
  • 91
  • 1
  • 4
  • 13
  • i solve by http://stackoverflow.com/questions/12324831/ios-store-more-than-one-password-in-keychain?rq=1 – SimonKira Apr 03 '13 at 01:51

2 Answers2

2

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.”
DBD
  • 23,075
  • 12
  • 60
  • 84
0

Specify a new key and store the value there

Lithu T.V
  • 19,955
  • 12
  • 56
  • 101