Dismiss second ViewController from the third ViewController

Viewed 2735

I am trying to dismiss VC b from VC c where VC c is a popover and has a button for sign out but it is not working. The structure of the flow is

VC a ----presents modally----> VC b ----presents a popover----> VC c

When the button in the popover is clicked the VC c and VC b must be dismissed so that (VC a)ViewWillAppear is called.

6 Answers
`protocol ModalHandler {
    func modalDismissed()
Class SecondViewController: UIViewController, ModalHandler {
    func modalDismissed() {
        self.dismiss(animated: false, completion: nil)
   }
   func open3rdController() {
       let thirdVC = ThirdViewController(_ )
       thirdVC.delegate = self
       self.present(thirdVC, animated: true, completion: nil)
   }
class ThirdViewController: UIViewController {
    func dismiss() {
        self.delegate.modalDismissed()
   }
}
`

Whats about a Presenter or a Coordinator.

This instance will initialize all these VCs and also present them. From there you can also dismiss them.

Related