I’ve read about Coordinator
pattern and in all cases it is described as below:
class SomeViewController: UIViewController {
weak var coordinator: CoordinatorProtocol?
}
protocol CoordinatorProtocol: AnyObject { }
class Coordinator: CoordinatorProtocol {
var navigationController: UINavigationController
func showSomeViewController() {
navigationController.push(SomeViewController(), animated: true)
}
}
But what to do if I need to add Coordinator2
(CoordinatorProtocol2
) which is independent from Coordinator
but it can create and use SomeViewController
? In other words how to make SomeViewController
using 2 or more coordinators?
Add weak var coordinator: CoordinatorProtocol2?
inside view controller? Replace with weak var coordinator: (CoordinatorProtocol1 & CoordinatorProtocol2)?
?