I want to switch the ViewController on load when the user is already logged in. The problem: The view didnt change when user is equal to "true"...
Thank you in advance!!
override func viewDidLoad() {
super.viewDidLoad()
var user: String?
user = UserDefaults.standard.value(forKey: "loginSuccessfull") as? String
if user == "true" {
let vc = self.storyboard?.instantiateViewController(withIdentifier: "SecondView") as UIViewController!
self.show(vc!, sender: vc)
}
// Do any additional setup after loading the view, typically from a nib.
}
Remove the code from
viewDidLoad
method and use the below method.