Maintained by Filippo Tosetto.
Depends on: | |
Alamofire | ~> 2.0 |
SwiftyJSON | ~> 2.3.0 |
Swift Open Weather Map API is a wrapper around OpenWeatherAPI
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)
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
The following methods are available at this time:
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)
forecast by city name:
public func forecastWeatherByCityNameAsJson(cityName: String, data: (JSON) -> Void)
forecast by coordinate:
public func forecastWeatherByCoordinatesAsJson(coordinates: CLLocationCoordinate2D, data: (JSON) -> Void)
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 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)