I have 3 views with 3 controllers: HomeView -> LoginView -> AccountView
In HomeView I added a NavigationBarController. When the user logs in in the LoginView, he is moved to the AccountView. When He clicks on the back button in the NavigationBar, he is sent to the LoginView and this is the problem. After logging if the user clicks on the back button, I want to show him the HomeView and not the LoginView. I tried this code but it takes some time to be executed and I can see the LoginView for some milliseconds.
override func viewWillAppear(animated: Bool) {
if let token = userDefaults.valueForKey("token") { //User logged in
self.performSegueWithIdentifier("homeSegue", sender: self)
}
}
Is there another way to do it?