I need write some code to switch the view to another tab when the iOS app starts (so, for example, the second tab is shown by default rather than the first).
I\'m ne
To expand on @codester's answer, you don't need to check and then assign, you can do it in one step:
func application(application: UIApplication!, didFinishLaunchingWithOptions launchOptions: NSDictionary!) -> Bool {
// Override point for customization after application launch.
if let tabBarController = self.window!.rootViewController as? UITabBarController {
tabBarController.selectedIndex = 1
}
return true
}