This is how my app is structured.
MainViewController (UITabViewController) --> VC1 (UIViewController) --> AddVC (UIViewController)
--> VC2 (UIViewController)
--> VC3 (UIViewController)
I want to add quick actions to my app, so I can access the AddVC when I press the action button from AppDelegate.
VC1 has an Add button which uses a segue to go to AddVC.
This is how I am trying to do: create the AddVC view controller and then MainViewController and from this I retrieve the VC1 with which I try to present the AddVC screen.
func application(_ application: UIApplication, performActionFor shortcutItem: UIApplicationShortcutItem, completionHandler: @escaping (Bool) -> Void) {
let vc = storyboard.instantiateViewController(withIdentifier: "AddVC") as! AddVC
switch shortcutItem.type {
case "Add":
let mainVC = app?.getRootViewController() as! MainViewController
let vc1 = mainVC.getVC1()
DispatchQueue.main.async {
vc1?.present(vc, animated: true, completion: nil)
}
}
When I do this, it always go to VC1 view controller, but not to the AddVC, so the segue is not performed.
I also tried using performSegue inside the DispatchQueue, same effect.
Anyone has an idea how can I make this work ?