Skip to content

Instantly share code, notes, and snippets.

@efremidze
Last active August 30, 2018 01:50
Show Gist options
  • Save efremidze/f6d1d9139a3df3d78993bbb6c37d47f9 to your computer and use it in GitHub Desktop.
Save efremidze/f6d1d9139a3df3d78993bbb6c37d47f9 to your computer and use it in GitHub Desktop.
Instantiate UIViewController Protocol
protocol Instantiatable {}
extension Instantiatable where Self: UIViewController {
static func instantiate() -> Self {
return UIStoryboard(name: "Main", bundle: nil).instantiateViewController(withIdentifier: String(describing: self)) as! Self
}
}
extension UIViewController: Instantiatable {}
let viewController = ViewController.instantiate()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment