我正在使用 keychainWrapper。 ios 中的钥匙串(keychain)使用预定义的常量存储,它们是:
kSecAttrAccessGroup
kSecAttrCreationDate
kSecAttrModificationDate
kSecAttrDescription
kSecAttrComment
kSecAttrCreator
kSecAttrType
kSecAttrLabel
kSecAttrIsInvisible
kSecAttrIsNegative
kSecAttrAccount
kSecAttrService
kSecAttrGeneric
这是否意味着我可以使用的钥匙串(keychain)数量有限?我曾经使用过自定义 key ,但它不起作用:
KeychainItemWrapper *keychain = [[KeychainItemWrapper alloc] initWithIdentifier:[[NSBundle mainBundle] bundleIdentifier] accessGroup:nil];
[keychain setObject:[[[UIDevice currentDevice] identifierForVendor] UUIDString] forKey:@"myUDID"];
但是这样做:
[keychain setObject:[[[UIDevice currentDevice] identifierForVendor] UUIDString] forKey:(__bridge NSString *)kSecValueData];
那么,有没有办法让我存很多钥匙串(keychain)?我可以用不同的标识符初始化我的钥匙串(keychain)以节省更多钥匙串(keychain)吗?像这样:
anotherKeychain = [[KeychainItemWrapper alloc] initWithIdentifier:@"TestUDID" accessGroup:nil];
[anotherKeychain setObject:udid forKey:(__bridge id)(kSecAttrAccount)];
最佳答案
您可以拥有任意数量的钥匙串(keychain)项(您所说的钥匙串(keychain)实际上是钥匙串(keychain)项)。每个项目只定义了有限数量的属性——你已经列出了这些。标识符是您喜欢的任何字符串,数据是您要针对该项目存储的值。
您还可以使用许多框架来简化事情 - http://cocoapods.org/?q=Keychain
关于ios - 我可以在 iOS 中存储多少个钥匙串(keychain)?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/33094631/