Last active
October 21, 2022 10:03
-
-
Save AashirMubeeb/46a08fe2fa148a6de2519f64705ae9a4 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
usage
guard let vc = AppStoryboard.Main.viewController(vc: HomeVC.self) as? HomeVC else{return UIViewController()}