Ash*_*wal 5 keychain ios uickeychainstore
我正在尝试在我的iOS应用程序中实现KeyChain共享,以在不同的iOS应用程序之间共享密码.
我正在使用该库UICKeyChainStore来实现此目的.
AppDelegate.m(这个有效)
self.keychainStore = [UICKeyChainStore keyChainStoreWithService:@"PasswordService" accessGroup:@"group_name"];
self.keychainStore[@"password"] = @"abcd1234";
NSLog(@"%@", self.keychainStore[@"password"]);
Run Code Online (Sandbox Code Playgroud)
在我的ViewController的ViewDidLoad方法中,相同的代码只是在控制台中打印(null).
AppDelegate *appDelegate = (AppDelegate *)[[UIApplication sharedApplication] delegate];
appDelegate.keychainStore[@"p2"] = @"1234";
NSLog(@"%@", appDelegate.keychainStore[@"p2"]);
Run Code Online (Sandbox Code Playgroud)
当我深入挖掘库时,抛出的错误消息是:
Error Domain = com.kishikawakatsumi.uickeychainstore Code = -34018"发生了安全错误." UserInfo = 0x174e76540 {NSLocalizedDescription =发生了安全错误.}