我想使用设置包从应用程序中注销。
func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplicationLaunchOptionsKey: Any]?) -> Bool {
//enable_logout key for logout switch identifire in setting budle plist.
let userLogout = UserDefaults.standard.bool(forKey: "enabled_logout")
print(userLogout)
let userLogin = UserDefaults.standard.bool(forKey: "isUserLogin")
if userLogin {
let homeController = HomeController()
let homeNav = UINavigationController.init(rootViewController: homeController)
let aboutController = AboutController()
let aboutNav = UINavigationController.init(rootViewController: aboutController)
let userBaseController = UserBaseInfoController()
let userBaseNav = UINavigationController.init(rootViewController: userBaseController)
tabbarController.viewControllers =[homeNav,userBaseNav,aboutNav]
self.window?.rootViewController = tabbarController
}
else {
let login = LoginController()
self.window?.rootViewController = login
}
return true
}
我在 appDelegate 中添加了此代码,我想当用户在设置中启用注销开关然后返回到应用程序显示登录视图时,但是当启用开关并返回到应用程序 appDelegate 时不会调用并且我的密钥不会更改。