Created
September 7, 2017 02:11
-
-
Save nikans/53c3ea146ceb12dc8461f7ba8a81793d to your computer and use it in GitHub Desktop.
Cannot initialize Presenter(dispatcher: dispatcher, view: self)
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
import UIKit | |
protocol ListPDOCommonType { | |
} | |
protocol ListDispatcherType { | |
init() | |
} | |
protocol ListViewType: class { | |
associatedtype PDO: ListPDOCommonType | |
func setList(_ list: PDO?) | |
} | |
protocol ListPresenterType { | |
associatedtype Dispatcher: ListDispatcherType | |
associatedtype View: ListViewType | |
init(dispatcher: Dispatcher, view: View) | |
func attachView(_ view: View) | |
} | |
class ListPresenter<Dispatcher: ListDispatcherType, View: ListViewType>: ListPresenterType { | |
internal let dispatcher: Dispatcher | |
weak internal var view : View? | |
required init(dispatcher: Dispatcher, view: View) { | |
self.view = view | |
self.dispatcher = dispatcher | |
} | |
func attachView(_ view: View) { | |
self.view = view | |
} | |
} | |
class AbstractListViewController<Presenter: ListPresenterType, PDO: ListPDOCommonType> | |
: UIViewController, ListViewType | |
where Presenter.View.PDO == PDO { | |
typealias Dispatcher = Presenter.Dispatcher | |
fileprivate var dispatcher: Dispatcher! | |
fileprivate var presenter: Presenter! | |
func configure() { | |
dispatcher = Dispatcher() | |
presenter = Presenter(dispatcher: dispatcher, view: self) | |
} | |
override func viewWillAppear(_ animated: Bool) { | |
presenter.attachView(self) | |
} | |
func setList(_ list: PDO?) { | |
// | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment