Created
September 1, 2020 04:28
-
-
Save cristhianleonli/f16a8f612a0c80cdd8affb87c551ceef to your computer and use it in GitHub Desktop.
This file contains 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 { | |
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