title: How to pass a Type of UIViewController to a function and type cast a variable in iOS Swift?
body: <p><strong>Explanation</strong></p>
  
  <p>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</p>
  
  <p><strong>Reference Code</strong></p>
  
  <pre><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)
      }
  </code></pre>