Skip to content

Instantly share code, notes, and snippets.

@elefantel
Last active March 17, 2017 22:18
Show Gist options
  • Save elefantel/06f8fd3bab400bbfc4904914bd2e8c74 to your computer and use it in GitHub Desktop.
Save elefantel/06f8fd3bab400bbfc4904914bd2e8c74 to your computer and use it in GitHub Desktop.
public extension UIViewController {
class var storyboardID: String {
return "\(self)"
}
public func instantiateViewController<T: UIViewController>(viewControllerClass: T.Type, inStoryboard: String, ofModule: Bundle?) -> T {
let storyboard = UIStoryboard(name: inStoryboard, bundle: ofModule)
return storyboard.instantiateViewController(withIdentifier: viewControllerClass.storyboardID) as! T
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment