Assembly
class LoginAssembly {
static func assemble() -> UIViewController {
let view = LoginViewController()
let interactor = LoginInteractor()
let router = LoginRouter(view: view)
let presenter = LoginPresenter(interface: view, interactor: interactor, router: router)
view.presenter = presenter
interactor.presenter = presenter
return view
}
}
Protocols
// MARK: Router -
protocol LoginRouterProtocol: class {
}
// MARK: Presenter -
protocol LoginPresenterProtocol: class {
}
// MARK: Interactor -
protocol LoginInteractorOutputProtocol: class {
/* Interactor -> Presenter */
}
protocol LoginInteractorInputProtocol: class {
/* Presenter -> Interactor */
}
// MARK: View -
protocol LoginViewProtocol: class {
/* Presenter -> ViewController */
}
Interactor
class LoginInteractor: LoginInteractorInputProtocol {
weak var presenter: LoginInteractorOutputProtocol?
}
Presenter
class LoginPresenter: LoginPresenterProtocol, LoginInteractorOutputProtocol {
weak private var view: LoginViewProtocol?
private let interactor: LoginInteractorInputProtocol
private let router: LoginRouterProtocol
init(interface: LoginViewProtocol,
interactor: LoginInteractorInputProtocol,
router: LoginRouterProtocol) {
self.view = interface
self.interactor = interactor
self.router = router
}
}
Router
class LoginRouter: LoginRouterProtocol {
weak private var viewController: UIViewController?
init(view: UIViewController) {
self.viewController = view
}
}
View
class LoginViewController: UIViewController, LoginViewProtocol {
var presenter: LoginPresenterProtocol?
override func viewDidLoad() {
super.viewDidLoad()
}
}