Skip to content

Instantly share code, notes, and snippets.

@strzempa
Created October 11, 2019 05:23
Show Gist options
  • Save strzempa/f626c6602effa2d891da120c7dfa17c1 to your computer and use it in GitHub Desktop.
Save strzempa/f626c6602effa2d891da120c7dfa17c1 to your computer and use it in GitHub Desktop.
import UIKit
public extension UINavigationController {
func popBack(to vc: AnyClass, animated: Bool = true) {
guard let elementFound = (viewControllers.filter { $0.isKind(of: vc) }).first else {
assertionFailure("cannot pop back to \(vc) as it is not in the view hierarchy")
return
}
self.popToViewController(elementFound, animated: animated)
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment