Member-only story

Decouple Your Classes in Swift

The MVC Architecture in Swift: A Practical Example

Steven Curtis
3 min readMay 5, 2023
Photo by OPPO Find X5 Pro on Unsplash

Before we start

Difficulty: Beginner | Easy | Normal | Challenging
This article has been developed using Xcode 12.1, and Swift 5.3

Prerequisites:

Terminology

Coupling: The degree of interdependence between software modules and classes
protocol: A blueprint on methods, properties and requirements to suit a piece of functionality

Coupling

Coupling is the degree of interdependence between software modules, and how closely connected they are.

A low degree of coupling is seen as good design, since low coupling can assist with reuse as well as readability and maintainability.

Coupling Using a Segue for Navigation

If we are trying to move between View Controllers using a Storyboard, we might well use code that has prepare(for:sender) and use this to pass data to a DetailViewController.

--

--

No responses yet