Select a tab bar item programmatically (not using UITabBarController)

Swift 3:

tabBarController.selectedIndex = 0 // (or any other existing index)

if you inside UITabBarController you can useself.selectedIndex = // set target index


In swift if tabbar is used not tabbarcontroller set default select

var tabbar:UITabBar?//if declare like this

tabbar!.selectedItem = self.tabbar!.items![0] as? UITabBarItem

or

let tabbar = UITabBar()//if declare and initilize like this

tabbar.selectedItem = self.tabbar.items![0] as? UITabBarItem

[tabBar setSelectedItem: [tabBar.items objectAtIndex:0]];

Which in swift, I think would be:

tabBar.selectedItem = tabBar.items![0] as UITabBarItem