简体   繁体   English

我们如何验证数据已保存到钥匙串中?

[英]How can we verify data is saved into keychain?

I'm using the UICKeyChainStore framework to save data to keychain. 我正在使用UICKeyChainStore框架将数据保存到钥匙串。

How can I verify that the data is saved to the keychain? 如何验证数据已保存到钥匙串?

You can get data back after storing in this way: 您可以通过以下方式获取数据:

NSString *name = [UICKeyChainStore stringForKey:@username" service:@"username"];

and then compare the strings to make sure that the value is saved 然后比较字符串以确保该值已保存

Alternatively, you can also use the following library. 或者,您也可以使用以下库。 https://gist.github.com/dhoerl/1170641 https://gist.github.com/dhoerl/1170641

UICKeyChainStore's setString forKey method returns the bool value , You can add a check on it. UICKeyChainStore的setString forKey方法返回bool值,您可以对其进行添加检查。

BOOL result = [UICKeyChainStore setString:@"value" forKey:@"key"];
    if (result) {
        NSLog(@"data saved successfully");
    } else {
        NSLog(@"problem in saving");
    }

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM