0

The reason for
tabBarController?.selectedIndex = 1
is not working, is that tabBarController is nil.
In order to get the right tabBarController, you will have to get it from the root of window object.
Something like this,
var tabBarController: UITabBarController = self.window?.rootViewContro...