Skip to content

Instantly share code, notes, and snippets.

@rayfix
Created April 21, 2018 16:27
Show Gist options
  • Save rayfix/3fff9695247aa1b9b6979557c5463de0 to your computer and use it in GitHub Desktop.
Save rayfix/3fff9695247aa1b9b6979557c5463de0 to your computer and use it in GitHub Desktop.
extension StoryboardInitializable where Self: UIViewController {
static var storyboardName: String {
return "Main"
}
static var storyboardBundle: Bundle? {
return nil
}
static var storyboardIdentifier: String {
return String(describing: self)
}
static func makeFromStoryboard() -> Self {
let storyboard = UIStoryboard(name: storyboardName, bundle: storyboardBundle)
return storyboard.instantiateViewController(withIdentifier: storyboardIdentifier) as! Self
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment