So I have a root view controller that has a button that when the user pushes it, another view controller is presented. This second controller has a dismiss option that just
The error occurs because you are trying to present SecondController from FirstController after you have dismissed FirstController. This doesn't work:
self.dismiss(animated: true, completion: {
let vc = SecondController()
// 'self' refers to FirstController, but you have just dismissed
// FirstController! It's no longer in the view hierarchy!
self.present(vc, animated: true, completion: nil)
})
This problem is very similar to a question I answered yesterday.
Modified for your scenario, I would suggest this:
weak var pvc = self.presentingViewController
self.dismiss(animated: true, completion: {
let vc = SecondController()
pvc?.present(vc, animated: true, completion: nil)
})