UISplitview: access UITabBarController from appDelegate
<p>I need to access the UITabBarController, and the second of its subviews from the appDelegate.</p>

<p><a href="https://i.stack.imgur.com/yVexM.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/yVexM.png" alt="Storyboard with UISPlitViewCOntroller as root"></a></p>

<p>This is what I have tried in applicationDidEnterBackground:</p>

<pre><code>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)")
</code></pre>

<p>The app crashes, complaining that tabController is nil. If i remove the UINavigation controller from storyboard, the UITabBarController is accessed easily with:</p>

<pre><code>let tabController = splitViewController.viewControllers.first as! UITabBarController
</code></pre>

<p>What is the correct way to access the childcontrollers of the UITabBarController, where a UISplitView is the root?</p>