Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Select an option

  • Save rlnucci/b8e61658e853f4a963c64ce955206788 to your computer and use it in GitHub Desktop.

Select an option

Save rlnucci/b8e61658e853f4a963c64ce955206788 to your computer and use it in GitHub Desktop.
typealias CustomViewDelegate = UITableViewDelegate & UITableViewDataSource
protocol CustomViewProtocol where Self: UIView {
func render(data: String)
func renderLoadingState()
}
final class ExampleViewController: UIViewController {
private let customView: CustomViewProtocol
private let presenter: ExamplePresenter
init(customView: CustomViewProtocol, presenter: ExamplePresenter) {
self.customView = customView
self.presenter = presenter
super.init(nibName: nil, bundle: nil)
}
required init?(coder aDecoder: NSCoder) {
fatalError()
}
override func viewWillAppear(_ animated: Bool) {
super.viewWillAppear(animated)
// Should test it
customView.renderLoadingState()
presenter.fetchData()
}
override func loadView() {
view = customView
}
}
extension ExampleViewController: PresenterDelegate {
func didFetch(data: String) {
// test it
customView.render(data: data)
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment