Skip to content

Instantly share code, notes, and snippets.

@AashirMubeeb
Last active October 21, 2022 10:03
Show Gist options
  • Save AashirMubeeb/46a08fe2fa148a6de2519f64705ae9a4 to your computer and use it in GitHub Desktop.
Save AashirMubeeb/46a08fe2fa148a6de2519f64705ae9a4 to your computer and use it in GitHub Desktop.
import UIKit
enum AppStoryboard : String{
case Main = "Main"
case PreLogin = "Payment"
var instance : UIStoryboard {
return UIStoryboard(name: self.rawValue, bundle: Bundle.main)
}
func viewController<T>(vc : T.Type) -> T where T: UIViewController{
let identifier = String(describing: T.self)
return self.instance.instantiateViewController(withIdentifier:identifier) as! T
}
}
@AashirMubeeb
Copy link
Author

usage
guard let vc = AppStoryboard.Main.viewController(vc: HomeVC.self) as? HomeVC else{return UIViewController()}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment