Trigger function in VC when modal view is dismissed

Swift 3

In your main VC viewDidLoad add:

NotificationCenter.default.addObserver(self, selector: #selector(mainVc.functionName), name:"NotificationID", object: nil)

and add a function in main VC

func functionName() {

    // Do stuff

}

in FirstStartVC call the method with

NotificationCenter.default.postNotificationName("NotificationID", object: nil)

Hope this helps!


A simple edit on Swift 4

NotificationCenter.default.addObserver(self, selector: #selector(self.funcName), name: NSNotification.Name(rawValue: "NotificationID"), object: nil)

Put @objc before the function definition.

@objc func functionName() {

    // Do stuff

}

In your code, you have:

func saveNewUser(){
        self.delegation?.newUserAction()
        self.dismiss(animated: true, completion: nil)
    }
}

Simply write the code you want to run after dismissing in completion::

func saveNewUser() {
        self.delegation?.newUserAction()
        self.dismiss(animated: true, completion: { finished in
            // on completion
        })
    }
}

(You might not even need to say finished in or anything like that.)