The Clean Architecture: An Example

Today, I’d like to take an example iOS app written with an MVC architecture and show you what the example would be with a Clean Swift architecture. The example I’ve chosen to use is the Quiz app from chapter 1 of the 3rd edition of iOS Programming: The Big Nerd Ranch Guide.

The Quiz is a simple app that is like flash cards. It looks like this:

The Show Answer button will reveal the answer to the question and tapping on the Next Question button will display the next question.

The MVC Example

Click here to download the source code for the MVC version from Big Nerd Ranch’s site. The code is actually from the 6th edition.

Let’s look at the relevant code. Here’s the code for the view controller, ViewController.swift: Continue reading →