NEW: My new book Pro SwiftUI is out now – level up your SwiftUI skills today! >>

Advanced coordinators in iOS tutorial. Few questions to help me understand.

Forums > Swift

Hey guys. I am trying to understand Advanced coordinators in iOS tutorial but to me it feels very incomplete. There are many things that I cannot understand.

The fact that tutorial is being made as seperate chunks that tells you to go back to your original project, makes it hard to connect these elements all together.

Coordinator pattern is quite confusing to me so if anyone could answer on those question (or at least one question!) I would appreciate it:))

Questions are connected directly or no to this tutorial https://www.hackingwithswift.com/articles/175/advanced-coordinator-pattern-tutorial-ios

  1. When creating a coordinator pattern alongisde this tutorial, I've noticed that if you remove var childCoordinators: [Coordinator] { get set } from the whole flow of the app, the application is still working. Flow works as it supposed to. So what is the purpose of that array?
  2. When should we create a ChildCoordinator? Should we create it everytime there is a new VC that have multiple or even single destination? So for each View Controller that may push another View Controller (or may push few different ones depending perhaps on a Buttons) we shoud create a seperate ChildCoordinator? Should those ChildCoordinators interact with superior Child coordinators to them or should they rather interact directly with the Main Coordinator? If that depends, depends on what then?
  3. in "Passing data between view controllers" from the tutorial. Paul asks to reverse the proejct to the original one from the first tutorial about Coordinators. That confuses me as at this point as I am not sure how to connect this part of the tutorial with having child Coordinators. You cannot pass parameter in a function start(). I've just created another method instead and I am not using start() in my child coordinator. My question is, is that a correct way to do so? This is how I did this in another child Coordinator:

    
    class GoNextCoordinator: Coordinator {
    weak var parentCoordinator: BuyCoordinator?
    
    var childCoordinators = [Coordinator]()
    var navigationController: UINavigationController
    
    init(navigationController: UINavigationController) {
        self.navigationController = navigationController
    }
    
    func start() {
    }
    
    func pushVC(with parameter: Int) {
        let vc = GoNextVC(parameter: parameter)
        vc.coordinator = self
        navigationController.pushViewController(vc, animated: true)
    }
    }


> 4. it seems like, for someone who is unfamiliar with Coordinator pattern, coordinators create quite complicated flow between each other. Is it really that efficient? Is there any trade off when using them?
> 
> I hope all of it makes sense. If not please dont hesitate replying so I can precise further.

1      

Hacking with Swift is sponsored by Play

SPONSORED Play is the first native iOS design tool created for designers and engineers. You can install Play for iOS and iPad today and sign up to check out the Beta of our macOS app with SwiftUI code export. We're also hiring engineers!

Click to learn more about Play!

Sponsor Hacking with Swift and reach the world's largest Swift community!

Archived topic

This topic has been closed due to inactivity, so you can't reply. Please create a new topic if you need to.

All interactions here are governed by our code of conduct.

 
Unknown user

You are not logged in

Log in or create account
 

Link copied to your pasteboard.