Skip to content

Instantly share code, notes, and snippets.

@lahariganti
Last active November 10, 2020 12:14
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save lahariganti/56db9b6d7063e80736d8b8b4049ba1e0 to your computer and use it in GitHub Desktop.
Save lahariganti/56db9b6d7063e80736d8b8b4049ba1e0 to your computer and use it in GitHub Desktop.
protocol Storyboarded {
static func instantiate() -> Self
}
extension Storyboarded where Self: UIViewController {
static func instantiate() -> Self {
let id = String(describing: self)
let storyboard = UIStoryboard(name: "Main", bundle: Bundle.main)
return storyboard.instantiateViewController(identifier: id) as! Self
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment