I have a login screen LoginViewController and homescreen HomeScreenController which is pushed when the user is successfully logged in).
I have declared a variable for UserDefaults as below in a seperate class:
class User {
static var isLoggedIn = UserDefaults.standard.bool(forKey:"islogged")
}
When the user clicks login Button, the code is as below
ButtonAction:
{
User.isLoggedin = true
//Performsegue........to homescreen
}
ViewDidload {
if user.isloggedin == true {
//Performsegue......homescreen
}
else {
Show some alerts
}
}
Here in my case...nothing happens...sorry for the rough code since I am using my smartphone to ask this question.
Am I missing something in appdelegate or somewhere else. I just want to use the variables as it is because I don't want to change the entire code in my project. The project is actually complicated and I just made an example to make you guys understand my situation. This is not the exact code.