Created
December 15, 2015 23:31
-
-
Save jarsen/95b1203105d4a34129e6 to your computer and use it in GitHub Desktop.
This file contains 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 StoryboardInstantiable { | |
static var storyboardName: String { get } | |
static var storyboardIdentifier: String { get } | |
} | |
extension StoryboardInstantiable { | |
static func instantiateFromStoryboard() -> Self { | |
let storyboard = UIStoryboard(name: storyboardName, bundle: nil) | |
guard let vc = storyboard.instantiateViewControllerWithIdentifier(storyboardIdentifier) as? Self else { | |
fatalError("Instantiated view controller does not match type") | |
} | |
return vc | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment