Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save andyyhope/eb2a5794f65db8d0ff97 to your computer and use it in GitHub Desktop.
Save andyyhope/eb2a5794f65db8d0ff97 to your computer and use it in GitHub Desktop.
func instantiateViewController<T: UIViewController>() -> T where T: StoryboardIdentifiable {
guard let viewController = self.instantiateViewController(withIdentifier: T.storyboardIdentifier) as? T else {
fatalError("Couldn't instantiate view controller with identifier \(T.storyboardIdentifier) ")
}
return viewController
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment