I currently have the following function inside of my main view controller (View Controller A).
func myAction() {       
    let mainStoryboard = UIStoryboard(name: "Main", bundle: Bundle.main)
    let viewControllerC : UIViewController = mainStoryboard.instantiateViewController(withIdentifier: "ViewControllerC") as UIViewController
    self.present(viewControllerC, animated: false, completion: nil)
}
When View Controller A is currently displayed and myAction is called it works fine and displays viewControllerC.
But this function myAction can be called basically at any time. Sometimes even when View Controller A is not the current view controller on the screen. Sometimes when View Controller B is displayed this function still gets called. It gets called fine. But it doesn't load viewControllerC in that case.
I've also tried the following thinking that would display from whatever the active view controller is. But that didn't work either.
self.view.window?.rootViewController?.present(viewControllerC, animated: false, completion: nil)
How can I get it to display viewControllerC when myAction is called no matter what view controller is currently being displayed?
 
     
     
    