I'm making twitter client app, using TwitterKit.
The initial VC is loginVC with login button. After login, it presents tableviewVC that shows list of tweets.
I want to redirect the user to tableviewVC directly if the user logged in already before and the session remains.
So I implemented codes in viewWillAppear that check logged-in users and present tableviewVC, but the tableviewVC never presented though the user session remains.
override func viewWillAppear(_ animated: Bool) {
super.viewWillAppear(animated)
if TWTRTwitter.sharedInstance().sessionStore.hasLoggedInUsers() {
let storyboard = UIStoryboard(name: "Main", bundle: nil)
let tweetVC = storyboard.instantiateViewController(withIdentifier: "TweetTableViewController")
present(tweetVC, animated: true, completion: nil)
}
}
But when I implemented the same codes in viewDidAppear, the tableviewVC showed up when the user session remains.
override func viewDidAppear(_ animated: Bool) {
super.viewDidAppear(animated)
if TWTRTwitter.sharedInstance().sessionStore.hasLoggedInUsers() {
let storyboard = UIStoryboard(name: "Main", bundle: nil)
let tweetVC = storyboard.instantiateViewController(withIdentifier: "TweetTableViewController")
present(tweetVC, animated: true, completion: nil)
}
}
I don't understand why it doesn't work when the codes are in viewWillAppear.
Could someone please explain it for me?