I have created a tab bar controller in storyboard, with 5 tab bar items. I want to remove one view controller programatically from the "viewcontrollers" array of the tab bar stack. I also want the app to be show some other tab item as selected when i remove the above view controller. I have tried with the below code, but its not working.
if let tabBarController = self.storyboard?.instantiateViewController(withIdentifier: "tabbar") as? UITabBarController {
tabBarController.viewControllers?.remove(at: 2)
tabBarController.selectedIndex = 1
}