I used the Objective-C code below to pop a specific ViewController.
Objective-C
ViewController
for (UIViewController *controller in self.navigationController.
swift5
let controllers : Array = self.navigationController!.viewControllers self.navigationController!.popToViewController(controllers[1], animated: true)