You could use NotificationCenter. I only do this if I need to update a view in the presenting view controller before dismissing the current view controller.
Add the following to the view controller that contains the method you are calling:
private let notification = NotificationCenter.default
override func viewDidLoad() {
super.viewDidLoad()
addObservers()
}
private func addObservers() {
notification.addObserver(self, selector: #selector(myMethod(_:)), name: Notification.Name.identifier, object: nil)
}
@objc
func myMethod(_ notification: Notification) {
// Do whatever
}
Then add the following to the view controller you are calling the method from:
func callTheMethod() {
NotificationCenter.default.post(name: Notification.Name.identifier, object: self, userInfo: nil)
}