Retrieving the actual forecast

We have almost completed the app, but it is still missing the most important part: the weather forecast.

Getting the forecast from OpenWeatherMap

There are plenty of services that provide forecasts for free or for a small amount of money.

For our app, we'll use http://openweathermap.org, whose API is free for a small number of calls.

First of all, we create the WeatherCondition struct to handle the forecast:

import Foundation struct WeatherCondition { let cityName: String? let weather: String let icon: IconType? let time: NSDate let tempKelvin: Double let maxTempKelvin: Double let minTempKelvin: Double var tempFahrenheit: Double { get { return tempCelsius * 9.0/5.0 + 32.0 } } var maxTempFahrenheit: Double { get { return ...

Get Swift: Developing iOS 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.