問題:
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