0

I am making an simple chatting app and I want to update to the latest messages when the user logs in. Right now the collection view cells do not update to the newest messages even though i call self.collectionView.reloadData() in ViewDidAppear. In my loginViewController I have a function where i pop to the root view controller(inbox), and I don't know how I can update the data before it pops to the inbox. As i said I am calling self.collectionView.reloadData() in the viewDidAppear and it does not update. When I run on simulator I have to go to the compose screen and go back to inbox before it updates the messages.

func signUpViewController(signUpController: PFSignUpViewController, didSignUpUser user: PFUser) {

  dismissViewControllerAnimated(true, completion: nil)
  self.navigationController?.popToRootViewControllerAnimated(true)

}

Does anyone know a fix?

1 Answers1

1

As your title suggests "PopToRootViewController" : I guess the code which will fetch recent messages is within viewDidLoad(). And viewDidLoad()is not called during PopToRootViewController.

Move the code which fetches recent messages into to the viewWillAppear() and see what happens.

Bista
  • 7,869
  • 3
  • 27
  • 55