【问题标题】:How many keyChain can I store in iOS?我可以在 iOS 中存储多少个 keyChain?
【发布时间】:2016-01-10 17:30:26
【问题描述】:

我正在使用 keychainWrapper。 ios中的钥匙串使用预定义的常量存储,它们是:

kSecAttrAccessGroup
kSecAttrCreationDate
kSecAttrModificationDate
kSecAttrDescription
kSecAttrComment
kSecAttrCreator
kSecAttrType
kSecAttrLabel
kSecAttrIsInvisible
kSecAttrIsNegative
kSecAttrAccount
kSecAttrService
kSecAttrGeneric

这是否意味着我可以使用的钥匙串数量有限?我曾经使用过自定义密钥,但它不起作用:

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];

那么,无论如何我可以保存许多钥匙串吗?我可以用不同的标识符初始化我的钥匙串以保存更多的钥匙串吗?像这样:

anotherKeychain = [[KeychainItemWrapper alloc] initWithIdentifier:@"TestUDID" accessGroup:nil];
[anotherKeychain setObject:udid forKey:(__bridge id)(kSecAttrAccount)];

How to store a string in KeyChain , iOS?

【问题讨论】:

  • 您可以拥有任意数量的钥匙串项(您所说的钥匙串实际上是钥匙串项)。每个项目只定义了有限数量的属性 - 您已经列出了这些。标识符是您喜欢的任何内容,数据是您要针对该项目存储的值
  • 还有一些框架可以用来简化事情 - cocoapods.org/?q=KeychAin
  • @Paulw11 感谢 Paul 指出这一点。确认一下,你是说我可以拥有任意多的keychainsItem,只要它们在init方法中的标识符不同,对吧?
  • @Paulw11 你是对的。我刚刚测试了它,它可以工作!您应该将其发布为您的答案,以便我可以接受:p

标签: ios keychain keychainitemwrapper


【解决方案1】:

您可以拥有任意数量的钥匙串项目(您所说的钥匙串实际上是钥匙串项目)。每个项目只定义了有限数量的属性 - 您已经列出了这些。标识符是您喜欢的任何字符串,数据是您要针对该项目存储的值。

您还可以使用许多框架来简化事情 - http://cocoapods.org/?q=Keychain

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2012-05-21
    • 1970-01-01
    • 1970-01-01
    • 2013-12-11
    • 1970-01-01
    • 2019-07-27
    • 1970-01-01
    • 2019-11-26
    相关资源
    最近更新 更多