Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- public protocol StoryboardBased: class {
- static var storyboard: UIStoryboard { get }
- }
- public extension StoryboardBased {
- static var storyboard: UIStoryboard {
- return UIStoryboard(name: String(describing: self), bundle: Bundle(for: self))
- }
- }
- public extension StoryboardBased where Self: UIViewController {
- static func instantiate() -> Self {
- guard let vc = storyboard.instantiateInitialViewController() as? Self else {
- fatalError("The VC of \(sceneStoryboard) is not of class \(self)")
- }
- return vc
- }
- }
Add Comment
Please, Sign In to add comment