Skip to content

Instantly share code, notes, and snippets.

@jakubpetrik
Last active April 9, 2018 14:24
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save jakubpetrik/bd4fd5d69067fd3772a5c3f82a2ff407 to your computer and use it in GitHub Desktop.
Save jakubpetrik/bd4fd5d69067fd3772a5c3f82a2ff407 to your computer and use it in GitHub Desktop.
UIStoryboard+MakeController
extension UIStoryboard {
static func make<T: UIViewController>(_ type: T.Type) -> T {
let storyboard = UIStoryboard(name: String(describing: type), bundle: nil)
guard let instance = storyboard.instantiateInitialViewController() as? T else { fatalError() }
return instance
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment