Created
November 8, 2017 10:50
-
-
Save chrisleversuch/3fe991a5c389642468704331bbb77f6b to your computer and use it in GitHub Desktop.
MVP Example
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 MyViewContract: class { | |
} | |
protocol MyPresenterContract { | |
} |
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
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 { | |
} |
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
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