5

我正在尝试在我的 iOS 应用程序中实现 KeyChain 共享,以在不同的 iOS 应用程序之间共享密码。

UICKeyChainStore为此目的使用该库。

AppDelegate.m(这有效)

self.keychainStore = [UICKeyChainStore keyChainStoreWithService:@"PasswordService" accessGroup:@"group_name"];
self.keychainStore[@"password"] = @"abcd1234";
NSLog(@"%@", self.keychainStore[@"password"]);

在我的 ViewController 的 ViewDidLoad 方法中,相同的代码只是在控制台中打印 (null)。

AppDelegate *appDelegate = (AppDelegate *)[[UIApplication sharedApplication] delegate];
appDelegate.keychainStore[@"p2"] = @"1234";
NSLog(@"%@", appDelegate.keychainStore[@"p2"]);

当我深入研究图书馆时,抛出的错误消息是:

错误域=com.kishikawakatsumi.uickeychainstore 代码=-34018 “发生安全错误。” UserInfo=0x174e76540 {NSLocalizedDescription=发生安全错误。}

4

0 回答 0