• Coordinators are responsible for the presentation flow between view controllers. • View controllers have no knowledge about the context they are being used. The coordinator pattern protocol Coordinator: class { var childCoordinators: [Coordinator] { get set } }
enum DeepLink { case pay case transfer case pendingPayments case accountDetail(id: String) } protocol Coordinator: class { var childCoordinators: [Coordinator] { get set } func open(deepLink: DeepLink, animated: Bool) }
Back to basics • Just use view controllers directly? • Can get the separation using parent/child view controllers • Hard to reuse sub-flows in navigation controllers
What about deep linking? • We no longer have a tree of coordinators • Traverse the view controller hierarchy instead • Need to associate a given view controller with something
struct DeepLink { let destination: Destination let path: [Destination] } enum Destination { case home case payments case spending case profile case pay case transfer case pendingPayments case accountDetail(id: String) }