Securing a Dictionary

Securing a more complex data type such as a dictionary follows the same approach taken to secure the PIN in earlier sections. The Keychain wrapper only allows for the storage of strings; to secure a dictionary, it is first turned into a string. The approach chosen for the sample code is to first save the dictionary to a JSON string using the NSJSONSerialization class. (See Chapter 7, “Working with and Parsing JSON,” for more info.)

NSMutableDictionary *secureDataDict = [[[NSMutableDictionary alloc] init] autorelease];NSError *error = nil;if(numberTextField.text)    [secureDataDict setObject:numberTextField.text forKey:@"numberTextField"];if(expDateTextField.text)    [secureDataDict setObject ...

Get iOS Components and Frameworks: Understanding the Advanced Features of the iOS SDK now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.