Skip to content

Instantly share code, notes, and snippets.

@shabib87
Created May 10, 2019 23:49
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save shabib87/c311d48c206cb013c42ea7d17ef9d189 to your computer and use it in GitHub Desktop.
Save shabib87/c311d48c206cb013c42ea7d17ef9d189 to your computer and use it in GitHub Desktop.
Helper root view controller class to enforce storyboard initialization without segues and handling dependency.
class RootViewController: UIViewController, StoryboardInitializable {
class func instantiateFromStoryboard(presenter aPresenter: Presenter) -> UIViewController {
fatalError("Override failed. Dependency injection not processed. Presenter injection hampered.")
}
// Preventing segue to support dependency injection
override func shouldPerformSegue(withIdentifier identifier: String, sender: Any?) -> Bool {
fatalError("Segues should not be used. Presenter injection hampered.")
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment