Mastering MVVM With Swift
Welcome to Mastering MVVM With Swift
Sponsors enable me to publish more free content. Take a moment to visit this week's sponsor to support the work I do.
Dream it. Build it. Grow it.
Get reliable and affordable cloud hosting with DigitalOcean! Our platform provides secure cloud infrastructure for developers. With simple pricing and flexible configurations, you can get up and running quickly. Plus, our 24/7 support ensures you're never alone.
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 11 and Swift 5
This series uses Xcode 11 and Swift 5. If you want to follow along, make sure you have Xcode 11 or later installed on your machine.
What You Will Learn
This series covers much more than the Model-View-ViewModel pattern. We start with an overview of the Model-View-ViewModel pattern and compare it to the Model-View-Controller pattern, a popular pattern you are 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 is something I want to show you first-hand. Writing unit tests for view models isn't difficult.
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 Combine. 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 am sure you will appreciate the benefits the Model-View-ViewModel pattern has to offer.
This series covers a lot of ground, but I am here to guide you along the way. If you would like to follow along with me, 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 are new to the Model-View-ViewModel pattern, then I recommend watching every episode of this series.