Better Programming

Advice for programmers.

Follow publication

Member-only story

Decoupling Concrete Coordinators From Your Navigation System in iOS

How to split navigation from coordinator instantiation using generic factory

Riccardo Cipolleschi
Better Programming
Published in
7 min readOct 21, 2021
Photo by Goran Ivos on Unsplash

MVVM is one of the most common architectures to realise apps. The goal of this architecture is to lighten the ViewController responsibilities by moving the presentation logic to another component, the ViewModel.

MVVM does not explain directly how to tackle the navigation from one ViewController to another. This issue is so important that a variant of MVVM has been developed: MVVM-C.

The MVVM-C architecture solves this problem by introducing a new set of components, the Coordinators. Their only responsibility is to properly handle the navigation.

Practically, whenever a ViewController completes its tasks, it invokes a method of the ViewModel that asks the Coordinator to go to the next screen.

This architecture works and all the responsibilities are clearly defined. The components are neatly divided and secluded: ViewControllers do not know the existence of other ViewControllers and ViewModels do not know the existence of other ViewModels.

The Coordinators are the components that know about the different Coordinators in the app. They work like glue, putting everything together.

Create an account to read the full story.

The author made this story available to Medium members only.
If you’re new to Medium, create a new account to read this story on us.

Or, continue in mobile web

Already have an account? Sign in

Riccardo Cipolleschi
Riccardo Cipolleschi

Written by Riccardo Cipolleschi

Hey there, I’m Riccardo. Software engineer at Meta. I have a passion for iOS and I love to share my knowledge with others.

Responses (1)

Write a response