single function to dismiss all open view controllers
I have an app which is a single view application. I have a navigation controller linked up to all child controllers from the root view controller. In each child controller, I have a logout button. I'm wondering if I can have a single function I can call which will dismiss all the controllers which have been open along along the way, no matter which controller was currently open when the user presses logout? My basic start: func tryLogout(){ self.dismissViewControllerAnimated(true, completion: nil) let navigationController = UINavigationController(rootViewController: UIStoryboard(name: "Main",