Last active
August 30, 2018 01:50
-
-
Save efremidze/f6d1d9139a3df3d78993bbb6c37d47f9 to your computer and use it in GitHub Desktop.
Instantiate UIViewController Protocol
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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