Model

The app needs a model that stores all of the information about the home screen. This model should contain a location, the current weather, and a detailed forecast for every hour until the end of the current day. It should also contain a forecast for the next 4 or 5 days. It's as simple as that. The model classes that follow fit these requirements. We could use a structure, not a class; it might have different fields, but this is our solution. This is the beauty of software development: many different classes, structures, and abstractions could lead to the same result:

public struct Location {    var name: String}     public class Forecast {    var date:Date    var weather:String = "undefined"    var temperature = 100          public init(date:Date, weather: ...

Get Learn Swift by Building Applications now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.