2015-10-13 57 views
0

我正在使用keychainWrapper。使用存儲在iOS上的鑰匙鏈預先定義的常量,它是這些:我可以在iOS中存儲多少個keyChain?

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?

+0

你可以有任意數量的鑰匙串項(你指的是什麼鑰匙鏈實際上是鑰匙串項)。每個項目只定義了數量有限的屬性 - 您已列出這些屬性。標識符是你喜歡的任何東西,數據是你想要存儲的對象的值 – Paulw11

+0

還有一些框架可以用來簡化事物 - https://cocoapods.org/?q=KeychAin – Paulw11

+0

@ Paulw11謝謝保羅指出了這一點。只需確認一下,你說我可以擁有儘可能多的keychainItem,只要它們在init方法中的標識符不同,對吧? – Eddie

回答

0

你可以有任意數量的鑰匙串項(你指的是鑰匙鏈實際上是鑰匙串項)。每個項目只定義了數量有限的屬性 - 您已列出這些屬性。標識符是您喜歡的任何字符串,並且數據是您想要針對該項目存儲的值。

也有很多的框架,您可以使用簡化的東西 - http://cocoapods.org/?q=Keychain

相關問題