O'Reilly logo

Swift 2 By Example by Giordano Scalzo

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Connecting to the server

Finally, we are ready to get the forecast data, and for that, we'll use a nice service called OpenWeatherMap, http://openweathermap.org, which offers a free tier as well.

To get access to the free tier, first of all we need to register to the site and then create a new API key, which will be passed as a parameter in every call to the server.

With this information, let's implement WeatherDatastore.

This class uses Alamofire, the Swift equivalent of AFNetworking, the most used third-party library to help handle network communications in iOS. It also uses SwiftyJson, which eliminates the problem of nested checks for optional values during the decoding of JSON (short for JavaScript Object Notation, a lightweight data interchange ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required