Skip to content

Instantly share code, notes, and snippets.

@chrisleversuch
Created November 8, 2017 10:50
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 chrisleversuch/3fe991a5c389642468704331bbb77f6b to your computer and use it in GitHub Desktop.
Save chrisleversuch/3fe991a5c389642468704331bbb77f6b to your computer and use it in GitHub Desktop.
MVP Example
protocol MyViewContract: class {
}
protocol MyPresenterContract {
}
class MyPresenter {
fileprivate weak var view: MyViewContract?
fileprivate let task: Task
init(view: MyViewContract, task: Task) {
self.view = view
self.task = task
}
}
// MARK: - MyPresenterContract
extension MyPresenter: MyPresenterContract {
}
class MyViewController: UIViewController {
fileprivate var presenter: MyPresenterContract?
convenience init(task: Task) {
self.init(nibName: nil, bundle: nil)
presenter = MyPresenter(view: self, task: task)
}
}
// MARK: - MyViewContract
extension MyViewController: MyViewContract {
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment