Explanation
I am defining a generic API method to handle popup across my application. Is it possible to pass a type of a UIViewController to a function and type cast the variable popOverVC in the function to the type of popUpVC ie., passed to the function as argument. All programs under Swift are appreciable
Reference Code
func showAsPopUp(currentVC: UIViewController,currentVCname: String, popupStoryboardID: String, popUpVC:UIViewController){
let popUpVCType:AnyClass = type(of: popUpVC)
let popOverVC = UIStoryboard(name: currentVCname, bundle: nil).instantiateInitialViewController(popupStoryboardID) as! popUpVCType
currentVC.addChildViewController(popOverVC)
}