title: How to change UITabViewController index after popping to root view controller in iOS Swift 5
body: <p>I have UITabbarController as root view controller. I need to pop to root view controller and change the selected index of the tab bar. </p>
  
  <p>I am using this code, it popus to tabbar but selected index is not changed</p>
  
  <pre><code>   self.navigationController?.popToRootViewController(animated: true)
  
      if let tab = self.tabBarController {
             tab.selectedIndex = 0      
      }
  </code></pre>
  
  <p>I have used this as an alternative as well, but still not success</p>
  
  <pre><code>    self.navigationController?.tabBarController?.selectedIndex = 0
  </code></pre>