If I exploit the weak
key phrase the coordinator is returning nil
class MainCoordinator: Coordinator {
var childCoordinators = [Coordinator]()
var navigationController: UINavigationController
init(navigationController: UINavigationController) {
self.navigationController = navigationController
}
func begin() {
let vc = ViewController()
vc.coordinator = self
navigationController.pushViewController(vc, animated: false)
}
}
class ViewController: UIViewController {
// var coordinator: MainCoordinator?
weak var coordinator: MainCoordinator?
override func viewDidLoad() {
tremendous.viewDidLoad()
guard let coordinator else {
print("Coordinator is nil")
return
}
}
}
be capable of use the coordinator