Member-only story
Decoupling The Segue In Swift
The MVC Architecture in Swift: A Practical Example
Before we start
Difficulty: Beginner | Easy | Normal | Challenging
This article has been developed using Xcode 12.2, and Swift 5.3
Prerequisites:
- I have already written an article on MVC, and the code in this article is based on that code
- This article leverages protocol
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 a 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
.