Better Programming

Advice for programmers.

Follow publication

Member-only story

Leverage the Coordinator Design Pattern in Swift 5

Isolate your view controllers to make them more testable and reusable

Zafar Ivaev
Better Programming
Published in
4 min readMar 18, 2020

--

Photo by Alvaro Reyes on Unsplash

In this tutorial, we’ll explore the coordinator design pattern in Swift through a sample project.

The coordinator pattern allows us to control the flow of our apps and avoid putting navigation logic directly into controllers. It also helps us isolate view controllers from each other, which comes in handy when we want to reuse them across our projects.

We’ll cover the following parts:

  • Creating individual coordinators
  • Leveraging the coordinator flow
  • Passing data between view controllers using coordinators

The source code of the project is available at the bottom of the article.

Let’s Start

First, let’s create the Coordinator protocol all of our coordinators will conform to:

--

--

Zafar Ivaev
Zafar Ivaev

Written by Zafar Ivaev

Senior iOS Engineer. I write about features of Swift and iOS development practices.

Responses (4)

Write a response