myriadmobile / BetterKit

A collection of useful tools to enhance standard application development
MIT License
0 stars 0 forks source link

UINavController pop to vc of type #5

Closed Janglinator closed 6 years ago

Janglinator commented 6 years ago

extension UINavigationController {

func popToFirstViewController<T: UIViewController>(ofType: T.Type, animated: Bool) {
    for vc in self.viewControllers {
        if let _ = vc as? T {
            self.popToViewController(vc, animated: animated)
        }
    }
}

}