Skip to content

A weather service interface for iOS projects using openweathermap.org

Notifications You must be signed in to change notification settings

scottgreiff/SGWeatherKit

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

17 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

SGWeatherKit

Carthage compatible

A weather service interface for iOS projects using openweathermap.org

About

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.

Requirements

  • Xcode 7.3+
  • iOS 8.0+
  • Swift 2.2+

Installation

github "scottgreiff/SGWeatherKit"

Documentation / Getting Started

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
  }
}

Credits

Created and maintained by @scottag.

Copyright © 2016-present Scott Greiff.

Please provide attribution, it is greatly appreciated.