popping to root view controller

By mlecoz

I have an alert whose OK button should pop to the root view controller.

Here’s the structure of what I’m working with:

[tab view controller] -> [navigation controller] -> [view controller] -> [view controller] -> [navigation controller] -> [view controller] -> [alert]

I would like the OK button on the alert take me to the view controller I’ve bolded above. When I do the code below, I go back to the view controller I’ve italicized above, which isn’t quite what I want. Any help would be much appreciated! Thanks!

alert.addAction(UIAlertAction(title: OK, style: UIAlertActionStyle.default, handler: { action in
    DispatchQueue.main.async(execute: {
        _ = self.dismiss(animated: true, completion: nil)
        })
}))

I have also tried using the special method for popping to the root view controller, but this has not worked, sadly.

Source: Stack Overflow

    

Share it with your friends!

    Fatal error: Uncaught Exception: 12: REST API is deprecated for versions v2.1 and higher (12) thrown in /home/content/19/9652219/html/wp-content/plugins/seo-facebook-comments/facebook/base_facebook.php on line 1273