I have already read: Programatically switching tabs using selectedViewController property
I am using XCode 10 and Swift 4.2 I run 2 lines of code in a ViewController.ViewDidAppear which is assigned to the second Tab Bar Item (index 1). Below myAppsTabBarController is a swift class that subclasses UITabBarController and has a static variable called myTabBarController that is assigned to self.
myAppsTabBarController.myTabBarController?.selectedIndex = 3
myAppsTabBarController.myTabBarController?.selectedViewController = myAppsTabBarController.myTabBarController?.viewControllers[3]
The first line works as I can see the 4th tab bar item light up (like it is selected.) The second line doesn't seem to work as the view doesn't update to the 4th tab. I have printed out myAppsTabBarController.myTabBarController?.viewControllers?.count and it is 4 so I know it exists. Any idea why the second line isn't changing the user's view? Thank you.