Reputation: 829
i have followed "GenericKeychain" sample app from apple & already able to write a string into keychain & also able to read it from keychain.
But i am wondering how can i store an array of string inside keychain, Is it possible ? How ?
Upvotes: 3
Views: 2298
Reputation: 81856
You can only store objects of type CFDataRef
(which is toll-free bridged to NSData
) in a keychain.
To store an array of strings you would typically use property list serialization:
NSArray *myArray = @[@"my", @"strings"];
NSData *data = [NSPropertyListSerialization dataWithPropertyList:myArray format: NSPropertyListBinaryFormat_v1_0 options:0 error:NULL];
Now you can put data
into the keychain.
Upvotes: 6