swift pop view controller pass data code example
Example 1: swift pop to specific view controller
let viewControllers: [UIViewController] = self.navigationController!.viewControllers
for aViewController in viewControllers {
if aViewController is YourViewController {
self.navigationController!.popToViewController(aViewController, animated: true)
}
}
Example 2: swift pop view controller
navigationController?.popViewController(animated: true)