I am attempting to keep the current user session active until the user decides to log out. What code i should i implement? and exactly where should it be implemented? the viewDidLoad, or viewWillAppear function of the root view? I have tried using this code in my root view:
override func viewDidAppear(animated: Bool) {
let vc = ViewController()
var loggedIn = false
if PFUser.currentUser() != nil {
loggedIn = true
} else {
presentViewController(vc, animated: true, completion: nil)
}
}
but whenever i stop the simulator and run it again, i have to log in all over again. What is the best solution? keep in my "ViewController" is my main view which holds my login/sign up fields. So i basically want a way to say if a current user session exist, continue, else, show initial view.