Hey guys. I am trying to understand the way that Coordinator works. I am cathing myself in building my own the way I shall not (created a function that passes a ViewController which, as I understand, defeats the purpose of a Coordinator.
Let us say I have 3 Diffrent ViewControllers that may be initialised from HomeVC depending on a Button. My way of thinking tells me to create something like this:
and just to initialize it in my VC. But it's not the way it supposed to be done I assume. Or is it actually?
Another way:
I have seen some tutorials when a guy used Enum for cases and created a separate function for each case. But then I don't know how would I pass some parameters while initializing another ViewController.
Or shall I rather create a function like the one above but for each individual View Controller and pass the parameter (let us say that VCs are initialized with the number: Int) in a function signature?
Many thanks for any any help!
Let us say I have 3 Diffrent ViewControllers that may be initialised from HomeVC depending on a Button. My way of thinking tells me to create something like this:
Code Block Swift class MainCoordinator: Coordinator { var navigationController: UINavigationController? func pushVCWithUser(viewController: UIViewController & Coordinating, isNavigationHidden: Bool) { var pushedVC: UIViewController & Coordinating = viewController pushedVC.coordinator = self navigationController?.setNavigationBarHidden(isNavigationHidden, animated: true) navigationController?.pushViewController(pushedVC, animated: true) } }
and just to initialize it in my VC. But it's not the way it supposed to be done I assume. Or is it actually?
Another way:
I have seen some tutorials when a guy used Enum for cases and created a separate function for each case. But then I don't know how would I pass some parameters while initializing another ViewController.
Or shall I rather create a function like the one above but for each individual View Controller and pass the parameter (let us say that VCs are initialized with the number: Int) in a function signature?
Many thanks for any any help!