Im trying to call popToRootViewController function from a view controller that is connected to a navigationController. When i removed that navigationController im able to go to my RootViewController. But if there is a navigation controller connected to (My case: TableViewController ) ViewController. the popToRootViewController will end up with the navigationController
override func tableView(_ tableView: UITableView, didSelectRowAt indexPath: IndexPath) {
if indexPath.section == 2 && indexPath.row == 0 {
Utilities.shared.clearTokens()
navigationController?.popToRootViewController(animated: false)
}
}

As i understand you want to popup to your root viewController when user click sign out you should cahnge the app root controller you can do it like this
because
navigationController?.popToRootViewController(animated: false)will pop to root controller on your current navigation stack