Last active
April 9, 2018 14:24
-
-
Save jakubpetrik/bd4fd5d69067fd3772a5c3f82a2ff407 to your computer and use it in GitHub Desktop.
UIStoryboard+MakeController
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
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