Tony's Weather App
A good example of a possible junior iOS developer job candidate take‑home project
The finished iPhone app will download weather data from a weather service provider called Open Weather, based in London. The user will be able to choose multiple locations from all over the world. We will focus more on the technical aspect of the app (meaning downloading data, saving data on disk, view transitions, clean code, comments where they are really needed), and less on making the user interface very pretty.
The app will have a black and white look, rather than gradients, colors, and shadows. This is a perfect project for a developer job candidate, not a for graphic designer job candidate.
Introduction of the project overall. The app will download weather data and display it to the user. The user will be able to choose from thousands of locations from all over the world.
We continue where we left off last time and dive into writing our first lines of code. The core of any app is the app logic, and a big part of the app logic is in the data models. What kind of data we will work with internally? How will that data be stored in memory? In this video, we will write our data models, make them Codable (and we learn what that means), and create a global public function that will read and decode our three JSON files we prepared last time, in order to populate our newly created data models with real data.
We will focus in this video on learning about enumerations (enums) and the Result data type, a special enum available in Swift 5. We will also learn about Swift extensions: what they are, what we can do in extensions, and what we cannot do, culminating with creating our first Swift extension. Then we will make a plan for refactoring our previously written JSON decoding function, so that this time our function will return a Result type instead of an optional custom structure. We will continue in the next video with implementing the plan developed in this video, so stay tuned...
We continue implementing our custom JSON decoding function, but this time by leveraging the powerful .flatMap function applied on a Result type. We will learn how to replace the function that we wrote last time (which was returning an optional custom structure), with another function that will instead return a Result of our custom structure. Advantages? The Result return type is an enum, and that means it will either return the decoded custom structure, if everything went well, OR it will give the caller an Error object, and that object will contain information about the cause of the decoding failure. Much better this way, to get some Error information when decoding failed, comparing to getting nothing (aka nil) like last time.
This video also touches on Swift's compiler powerful ability to infer type for variables and constants, which reduces substantially the amount of code we need to write, and most of all, we need to read. Using type inference together with the .flatMap function on Result, we will reduce our new function to a simple line of code.