问题:
I have a login-screen in my iOS app.我的 iOS 应用中有一个登录屏幕。 The username and password will be saved in the NSUserDefaults
and be loaded into the login-screen again when you enter the app again (of course, NSUserDefaults
are permanent).用户名和密码将保存在NSUserDefaults
并在您再次进入应用程序时再次加载到登录屏幕(当然, NSUserDefaults
是永久的)。
Now, the user have the possibility to disable the username/password saving feature.现在,用户可以禁用用户名/密码保存功能。
So the NSUserDefaults
will be cleared then.所以NSUserDefaults
将被清除。
But In my app I need this username/password for database queries for the user.但是在我的应用程序中,我需要这个用户名/密码来为用户查询数据库。 So: Where to store the data except NSUserDefaults
?那么:除了NSUserDefaults
之外,在哪里存储数据? (This place can / should be deleted when the user quit the app or logout). (当用户退出应用程序或注销时,这个地方可以/应该被删除)。
解决方案:
参考一: https://en.stackoom.com/question/TFl6参考二: https://stackoom.com/question/TFl6