I have a very weird problem in Swift3
. I want to keep an user logged into application after he has already authenticated in his last session.
My problem is that UserDefaults
return sometimes true, sometimes false even if is logged in his account. The problem makes me crazy. I use an bool
value stored in UserDefaults
, I tried to save a specific string but the problem persist.
Anyone had this problem? Any solutions?
Here is the code when I log in:
UserDefaults.standard.set(true, forKey: LOGIN)
And this is my code in AppDelegate
in didFinishLaunchingWithOptions
method:
if UserDefaults.standard.bool(forKey: LOGIN) {
AppData().updateUserInformation()
}