-1

So i need to write some code to help me dismiss the segue modally once the question VC (4th) sends a segue to the results VC (5th). I want the 5th VC to dismiss the segue modally to the Difficulty VC (3th) using the code

self.dismiss(animated: true, completion: nil)

allows me to dismiss to the previous VC, which is the Question VC. But how can I dismiss to the dificulty VC (3rd VC).

Thanks!

Oscar Ramos

Storyboad 5 VC's

code for the last VC

  • I answered a similar question about reaching a specific view controller (root) - maybe it could give you some ideas: https://stackoverflow.com/a/68127944/1619193. Sometimes you might have to change the way you navigate to a view controller to make it easier to reach a specific view controller in your view controller hierarchy. Navigation Controller stacks give you more control. – Shawn Frank Jan 13 '22 at 14:36

1 Answers1

0

You can make use of the completion handler of the dismiss(animated:completion:) method, like this:

vc5.dismiss(animated: true) { [vc4] in
    vc4.dismiss(animated: true)
}

For information about how this method works you can read the documentation.

Mo Abdul-Hameed
  • 6,030
  • 2
  • 23
  • 36