Building a Weather Application From Scratch
|2||Setting Up the Project 07:15|
|3||View Controller Containment 12:08|
|4||Fetching Weather Data 05:59|
|5||Removing Object Literals 07:54|
|6||Creating a View Model 13:09|
|7||Parsing the JSON Response 13:56|
|8||Handling Errors and Notifying the User 14:28|
|9||Adding Flexibility With Protocols 14:11|
|10||Creating the Day and Week View Models 07:33|
|11||Creating the User Interface of the Day View Controller 12:52|
|12||Organizing Fonts and Colors 06:45|
|13||Implementing the Day View Model 15:55|
|14||Writing Unit Tests for the Day View Model 12:57|
|15||Implementing the Week View Model 12:37|
|16||Writing Unit Tests for the Week View Model 07:10|
|17||Fetching Weather Data for the User's Location 13:32|
|18||Increasing Testability With Protocol-Oriented Programming 14:47|
|19||Replacing Optionals with Enums and Associated Values 09:30|
In Mastering MVVM With Swift, we refactor a weather application, Cloudy, built with MVC to use MVVM instead. One of the most common questions I receive is how to build Cloudy from scratch. This series is an answer to that question. We build a weather application that is inspired by Cloudy. The application is aptly named Rainstorm.
The goal of this series isn't to teach you Swift and Cocoa development. This series assumes that you have a basic understanding of the Swift language and the iOS SDK. The goal is to show you how to build a production application from start to finish. I show you how to set up the project, discuss the decisions I make along the way, and highlight key patterns that power the project.
Before we fire up Xcode and create the project, I'd like to give you a glimpse of what you can expect from this series. As I mentioned earlier, the project is powered by the Model-View-ViewModel pattern. It's a pattern I use in every project. It's easy to adopt and implement. I consider the Model-View-ViewModel pattern an improved version of the Model-View-Controller pattern.
The project also adopts view controller containment, another pattern I use in every project I work on. Navigation controllers, tab bar controllers, and split view controllers are UIKit components that take advantage of view controller containment.
Testing has become an important aspect in the Swift and Cocoa communities and we explore how to leverage unit tests to build a stable and robust application. Unit testing becomes much easier if you embrace dependency injection. If you're new to dependency injection, then this series shows you how easy it is to adopt. Dependency injection is also a potent solution for curing projects from singletonitis.
Most applications rely on the network to fetch data from a remote backend. The weather application we're about to build is no different. We fetch weather data from the Dark Sky API, an easy to use weather service. The requests the application performs aren't complex and we won't be relying on a third party networking library. The
URLSession API is more than sufficient.
Parsing the data we receive from the Dark Sky API isn't complicated thanks to the
Codable protocol. Working with JSON used to be tedious and clunky. That's no longer true.
There's much more you learn along the way, including working with storyboards and storyboard references, protocol-oriented programming, namespacing with enumerations, the power of value types, asynchronous programming, and debugging applications with Xcode.
This series also illustrates that you don't need rely on third party libraries to build an application. It's true that there are countless outstanding third party libraries available, but a third party library shouldn't be your first or default choice. It's important that you first become familiar with the native APIs before you consider a third party solution.
In the next episode, we fire up Xcode and set up the project. There's more to it thank you may think.