Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
我已经关注了来自苹果的“GenericKeychain”示例应用程序并且已经能够将字符串写入钥匙串并且还能够从钥匙串中读取它。
但我想知道如何在钥匙串中存储一个字符串数组,这可能吗?如何 ?
您只能将类型的对象CFDataRef(可免费桥接到NSData)存储在钥匙串中。
CFDataRef
NSData
要存储字符串数组,您通常会使用属性列表序列化:
NSArray *myArray = @[@"my", @"strings"]; NSData *data = [NSPropertyListSerialization dataWithPropertyList:myArray format: NSPropertyListBinaryFormat_v1_0 options:0 error:NULL];
现在您可以放入data钥匙串。
data