I am new to Swift (using 4 version) and I want to change tab bar item from another view controller (not tab bar controller).
This is my scheme:
From RouterViewController (used for side menu navigation) in didSelectRowAt i'm doing this:
func tableView(_ tableView: UITableView, didSelectRowAt indexPath: IndexPath) {
let mainViewController = sideMenuController!
let tabBarController : TabBarController = UIStoryboard(name: "Main", bundle: nil).instantiateViewController(withIdentifier: "TabBarController") as! TabBarController
tabBarController.selectedIndex = indexPath.row
}
It's not throwing any exceptions and debugging shows, that let tabBarController is not null, but it's not changing tab for some reason.
What am I doing wrong?