// // PopViewControllerGeneric.swift // WOKA // // Created by MacBook Pro on 20/08/24. // import UIKit /* this helps in navigation back or pop the viewcontroller as generic type */ extension UINavigationController { func getViewController(of type: T.Type) -> UIViewController? { return self.viewControllers.first(where: { $0 is T }) } func popToViewController(of type: T.Type, animated: Bool) { guard let viewController = self.getViewController(of: type) else { return } self.popToViewController(viewController, animated: animated) } }