我正在使用xcode8 + swift3开发iOS应用程序。
我创建了将用户密码存储到钥匙串并从钥匙串中读取密码的功能。您可以参考here了解我创建的功能。
我一般注意到的问题是,即使我卸载了应用程序,当我重新安装应用程序时,我的应用程序读取密码链中的密码是以前安装的应用程序(已经卸载的旧密码)。
我的问题是,解决这个问题的最佳做法是什么?
答案 0 :(得分:0)
在app delegate中你可以这样做:
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
{
BOOL savedInKeychain = [[NSUserDefaults standardUserDefaults]boolForKey:@"savedInKeychain"];
if(!savedInKeychain){
//There is no keychian data saved in this app
//check if data exisst in keychain
if(kechainData){
//Delete keychain data
}
return YES;
}
稍后将数据保存在钥匙串中后,在userdefaults中将savedInKeychain设置为YES。