Mastering MVVM With Swift

Welcome to Mastering MVVM With Swift

Welcome to Mastering MVVM With Swift. In this series, you learn the ins and outs of the Model-View-ViewModel pattern. The goal is to provide you with the ingredients you need to implement the Model-View-ViewModel pattern in your own projects.

Xcode 9 and Swift 4

This series uses Xcode 9 and Swift 4. If you want to follow along, make sure you have Xcode 9 installed on your machine.

What You'll Learn

This series covers much more than the Model-View-ViewModel pattern. We start with an overview of the Model-View-ViewModel pattern and we compare it with the popular Model-View-Controller pattern, a pattern you're probably already familiar with.

In the remainder of the series, we refactor Cloudy, a weather application powered by the Model-View-Controller pattern. We refactor Cloudy to use the Model-View-ViewModel pattern instead. This will show you how to apply the Model-View-ViewModel pattern in a production application. The refactoring operation will show you exactly what needs to change to move from MVC to MVVM, highlighting the benefits and challenges that go with this migration.

Along the way, you learn what view models are, how to create them, and how to use them in view controllers. We further simplify the view controllers of the project using protocol-oriented programming. Protocols and MVVM work very well together.

Later in the series, we write unit tests for the view models we created. One of the key benefits of the Model-View-ViewModel pattern is improved testability and that's something I want to show you first-hand. Writing unit tests for view models is really easy.

The Model-View-ViewModel pattern really shines with the help of bindings. I first show you how to create a custom bindings solution. This is an important step as it will show you how the Model-View-ViewModel pattern and bindings work under the hood.

Later in the series, we take it a step further by taking advantage of RxSwift and RxCocoa. You don't need to be familiar with reactive programming to understand these episodes. We primarily focus on the Model-View-ViewModel pattern and how it plays together with bindings. The Model-View-ViewModel pattern works with any bindings solution.

We end with a recap of what we gained from using the Model-View-ViewModel pattern instead of the Model-View-Controller pattern. The changes we apply to Cloudy are pretty dramatic and I'm sure you'll appreciate the benefits the Model-View-ViewModel pattern has to offer.

This series covers a lot of ground, but I'm here to guide you along the way.

Following Along

If you'd like to follow along, I recommend downloading the source files of each episode. The episodes that include code each have a starter project and a finished project. This makes it easy to follow along or pick a random episode of this series. If you're new to the Model-View-ViewModel pattern, then I recommend watching every episode of this series.

Next Episode "Is MVC Dead"

Stop Writing Swift That Sucks

Download the Swift Patterns I Swear By