Delegate on Delegate

43 Views Asked by At

I have a situation: I have a SideMenu and there is a Logout button on it. After the logout is triggered, 2 things are to be done:

  1. try Auth.auth().signOut() is to be done in Firebase
  2. self.navigationController?.dismiss(animated: true, completion: nil) is to be triggered

On the screenshot below (I will add description for those, who cannot see) I show the flow:

  1. Initial Controller; Class in storyboard - Empty leads to (segue has no name)
  2. Welcome Controller; Class in storyboard - WelcomeController (script) leads to (segue has no name)
  3. Menu Navigation Controller; Class in storyboard - empry leads to (segue has no name)
  4. New Main Controller; Class in storyboard - NewMainController leads to (segue has a name - burgerSegue)
  5. Side Navigation Controller (from pods SideMenu); Class in storyboard - SideNavigationController (as in documentation + module = SideMenu) leads to (segue has no name)
  6. ViewController (where I store my SideMenu); Class in storyboard - empty leads to (segue has a name - finalSegueToMenu)
  7. Menu Controller; Class in storyboard - SideMenuButtons (script)

Ideally, I was trying to connect NewMainController and MenuController with delegates.

This is what I had in MenuController:

    @IBAction func logoutClicked(_ sender: Any) 
    {
        if delegate == nil {
            print("Delegate is nil")
        } else {
            print("Delegate is set")
            delegate?.logoutClickedInSideMenu()
        }

        print("Logout button clicked")
    }

Yet, each time I got Delegate is nil.

Could it be that my whole approach is wrong and there is a simpler option?

Important: SideMenu is created in Storyboard, not in programmatically.

Thanks!

1) Initial Controller; Class in storyboard - Empty
leads to (segue has no name)
2) Welcome Controller; Class in storyboard - WelcomeController (script)
leads to (segue has no name)
3) Menu Navigation Controller; Class in storyboard - empry
leads to (segue has no name)
4) New Main Controller; Class in storyboard - NewMainController
leads to (segue has a name - burgerSegue)
5) Side Navigation Controller (from pods SideMenu); Class in storyboard - SideNavigationController (as in documentation + module = SideMenu)
leads to (segue has no name)
6) ViewController (where I store my SideMenu); Class in storyboard - empty
leads to (segue has a name - finalSegueToMenu)
7) Menu Controller; Class in storyboard - SideMenuButtons (script)

0

There are 0 best solutions below