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 ...
Get Swift 2 By Example 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.