Skip to content

Instantly share code, notes, and snippets.

@cristhianleonli
Created September 1, 2020 04:28
Show Gist options
  • Save cristhianleonli/f16a8f612a0c80cdd8affb87c551ceef to your computer and use it in GitHub Desktop.
Save cristhianleonli/f16a8f612a0c80cdd8affb87c551ceef to your computer and use it in GitHub Desktop.
extension UIStoryboard {
func instantiateViewController<T>(ofType type: T.Type = T.self) -> T where T: UIViewController {
let controller = instantiateViewController(withIdentifier: type.reuseId)
guard let viewController = controller as? T else {
fatalError()
}
return viewController
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment