I have issue with following code:
func generic1(name : String){
}
func generic2(name : String){
generic1(name)
}
To let compiler know what type he is dealing with pass the class as argument
extension UIViewController {
func navigate(_ dump: ControllerType.Type, id: String, before: ((ControllerType) -> Void)?){
let controller = self.storyboard?.instantiateViewController(withIdentifier: id) as! ControllerType
before?(controller)
self.navigationController?.pushViewController(controller, animated: true)
}
}
Call as:
self.navigate(UserDetailsViewController.self, id: "UserDetailsViewController", before: {
controller in
controller.user = self.notification.sender
})