swiftunwind-segue

Swift unwind issues, view controllers stack not updated


I unwind from controller B to controller A.

When I print my view controllers stack on my unwind function (controller A), I still have my controller B in stack.

Is it normal that after an unwind the controllers stack is not updated ?!

Controller B:

self.bookmarkViewController.performSegue(withIdentifier: "unwindToViewController", sender: nil)

Controller A

@IBAction func unwindToViewController(segue: UIStoryboardSegue) {
print(self.navigationController?.viewControllers)
}


Solution

  • Is it normal that after an unwind the controllers stack is not updated ?!

    Yes. At the point that unwindToViewController is called, the segue is not yet completed. For this reason, you can't push a new ViewController from this routine or trigger a new segue.

    When viewDidAppear runs, the viewControllers stack will have been updated.