SwiftOpenWeatherMapAPI 0.0.8

SwiftOpenWeatherMapAPI 0.0.8

Maintained by Filippo Tosetto.



 
Depends on:
Alamofire~> 2.0
SwiftyJSON~> 2.3.0
 

  • By
  • Filippo Tosetto

Swift Open Weather Map API

Swift Open Weather Map API is a wrapper around OpenWeatherAPI

Requirements

  • iOS 8.0+ / Mac OS X 10.9+
  • Xcode 7

Installation

Initialization

Include the header:

import SwiftOpenWeatherMapAPI

Setup the api:

// Setup weather api
let weatherAPI = WAPIManager(apiKey: "YOUR_API_KEY")

// Setup weather api with temperature format
let weatherAPI = WAPIManager(apiKey: "YOUR_API_KEY", temperatureFormat: .Celsius)

// Setup weather api with temperature format and language
let weatherAPI = WAPIManager(apiKey: "YOUR_API_KEY", temperatureFormat: .Celsius, lang: .English)

Getting data

The api is at this time just simple wrapper for the http-api.

weatherAPI.currentWeatherByCityNameAsJson("London") { (json) -> Void in
    //Do something with the data
}

The result is a JSON struct coming from mapping the api data using SwiftyJSON

Usage

The following methods are available at this time:

Current Weather

Current weather by city name:

public func currentWeatherByCityNameAsJson(cityName: String, data: (JSON) -> Void)

Current weather by coordinate:

public func currentWeatherByCoordinatesAsJson(coordinates: CLLocationCoordinate2D, data: (JSON) -> Void)

Forecasts (3 hour intervals)

forecast by city name:

public func forecastWeatherByCityNameAsJson(cityName: String, data: (JSON) -> Void)

forecast by coordinate:

public func forecastWeatherByCoordinatesAsJson(coordinates: CLLocationCoordinate2D, data: (JSON) -> Void)

Daily Forecasts

daily forecast by city name:

public func dailyForecastWeatherByCityNameAsJson(cityName: String, data: (JSON) -> Void)

daily forecast by coordinates:

public func dailyForecastWeatherByCoordinatesAsJson(coordinates: CLLocationCoordinate2D, data: (JSON) -> Void)

Historic Data

historic data by city name:

public func historicDataByCityNameAsJson(cityName: String, start: NSDate, end: NSDate?, data: (JSON) -> Void)

historic data by coordinates:

public func historicDataByCoordinatesAsJson(coordinates: CLLocationCoordinate2D, start: NSDate, end: NSDate?, data: (JSON) -> Void)