I need to access the UITabBarController, and the second of its subviews from appDelegate.

This is what I tried in applicationDidEnterBackground:
let splitViewController = self.window!.rootViewController as! UISplitViewController let leftNavController = splitViewController.viewControllers.first as! UINavigationController let tabController = leftNavController.tabBarController! as UITabBarController let controllers : Array = tabController.viewControllers! print("viewcontrollers \(controllers)")
The application crashes, complaining that the tabController is zero. If I remove the UINavigation controller from the storyboard, the UITabBarController is accessed using:
let tabController = splitViewController.viewControllers.first as! UITabBarController
What is the correct way to access the UITabBarController child controllers where the UISplitView is the root?
source share