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

ライブラリを深く掘り下げると、スローされるエラーメッセージは次のとおりです。

エラー Domain=com.kishikawakatsumi.uickeychainstore Code=-34018 「セキュリティエラーが発生しました。」UserInfo=0x174e76540 {NSLocalizedDescription=セキュリティ エラーが発生しました。}

4

0 に答える 0