Monday, February 12, 2024
HomeiOS Developmentswift - Coordinator in UIKit is nil? iOS 17, weak, reminiscence administration

swift – Coordinator in UIKit is nil? iOS 17, weak, reminiscence administration


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



Supply hyperlink

RELATED ARTICLES

LEAVE A REPLY

Please enter your comment!
Please enter your name here

- Advertisment -
Google search engine

Most Popular

Recent Comments