Guest User

Untitled

a guest
Feb 17th, 2018
63
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.52 KB | None | 0 0
  1. public protocol StoryboardBased: class {
  2. static var storyboard: UIStoryboard { get }
  3. }
  4.  
  5. public extension StoryboardBased {
  6. static var storyboard: UIStoryboard {
  7. return UIStoryboard(name: String(describing: self), bundle: Bundle(for: self))
  8. }
  9. }
  10.  
  11. public extension StoryboardBased where Self: UIViewController {
  12. static func instantiate() -> Self {
  13. guard let vc = storyboard.instantiateInitialViewController() as? Self else {
  14. fatalError("The VC of \(sceneStoryboard) is not of class \(self)")
  15. }
  16. return vc
  17. }
  18. }
Add Comment
Please, Sign In to add comment