A weather service interface for iOS projects using openweathermap.org
This Swift-based library aims to do the following:
- Provide CLLocation-based interface to weather information provided by openweathermap.org
For detailed information on the different api calls, check out the official page here.
- Xcode 7.3+
- iOS 8.0+
- Swift 2.2+
github "scottgreiff/SGWeatherKit"
import SGWeatherKit
To get the current weather conditions for a specific location:
let agent = WeatherKitAgent(apiKey: "your_api_key")
agent.currentWeather(CLLocationCoordinate2D(latitude: 39.961176, longitude: -82.998794)) { result in
if let city: City = result.data() {
// Do something with the current weather forecast city object here
}
}
To get the weather forecast for a specific location:
let agent = WeatherKitAgent(apiKey: "your_api_key")
agent.dailyForecast(CLLocationCoordinate2D(latitude: 39.961176, longitude: -82.998794)) { result in
if let city: City = result.data() {
// Do something with the forecast dictionary here
}
}
To get conditions for a specified number of cities near a specific location:
let agent = WeatherKitAgent(apiKey: "your_api_key")
agent.citiesInCycle(CLLocationCoordinate2D(latitude: 39.961176, longitude: -82.998794), numberOfCities: 10) { result in
if let city: [City] = result.data() {
// Do something with the city forecast dictionary here
}
}
Created and maintained by @scottag.
Copyright © 2016-present Scott Greiff.
Please provide attribution, it is greatly appreciated.