Skip to content

Latest commit

 

History

History
113 lines (94 loc) · 4.55 KB

README.md

File metadata and controls

113 lines (94 loc) · 4.55 KB

Build Status codecov Badge w/ Version || Swift Badge w/ Platform

⚠️ Message from author: ⚠️

Guys thanks for your incredible support of that project. I see that it was useful for somebody and that makes me really happy.
Anyway, since last years I was mainly working as cloud-native applications developer and was using other technologies, I have no
plans to update this SDK at all.

So, feel free to fork it and make your own implementation of it. There is no need to create issues / requests here.

OpenWeatherMapKit

OpenWeatherMapKit is a small and simple framework written in Swift that gives you access to all features of the OpenWeatherMap service's APIs right in your iOS / macOS / watchOS/ tvOS application.

How to install:

🥥 Cocoapods

Just add following line to your Podfile:

pod 'OpenWeatherMapKit'

and run following command in your Terminal from project's root folder:

pod update

How to use:

Prerequisites

To normal working OpenWeatherMapKit must be initialized with your API token.

You can use following method to initialize OpenWeatherMapKit. Just replace [YOUR API TOKEN] by your own API token which can be retrieved from https://home.openweathermap.org/api_keys:

 OpenWeatherMapKit.initialize(withAppId: "[YOUR API TOKEN]")

Usage

Use OpenWeatherMapKit class to retrieve weather data. It is a singleton and access to it's instance can be done through instance variable.

🌇 Get weather by City

You can retrieve weather data for specific city by it's name:

OpenWeatherMapKit.instance.currentWeather(forCity: "Samara") { (forecast, error) in
    ...
}

or event by city name and country code:

OpenWeatherMapKit.instance.currentWeather(forCity: "Samara", withCountryCode: "ru") { (forecast, error) in
    ...
}
🌍 Get weather by geo coordinates

You can retrieve weather data for specific geo location by it's coordinates:

OpenWeatherMapKit.instance.currentWeather(forCoordiante: (latitude: 53.2610313, longitude: 50.0579958)) { (forecast, error) in
    ...
}
📆 Get weather forecast for next 5 days

You can retrieve weather data for next five days for specific city by it's name and country code:

OpenWeatherMapKit.instance.weatherForecastForFiveDays(forCity: "Samara", withCountryCode: "ru") { (forecast, error) in
...
}

or for specific geo location by it's coordinates:

OpenWeatherMapKit.instance.weatherForecastForFiveDays(forCoordiante: (latitude: 53.2610313, longitude: 50.0579958)) { (forecast, error) in
...
}
🌤 WeatherItem

All operations for getting current weather data return special object of WeatherItem type. WeatherItem is a simple struct that contains temperature data on the board. Here are fields you can access on it:

/// Weather item's temperature values in Kelvin
public let kelvin: (currentTemp: Double, maxTemp: Double, minTemp: Double)
/// Weather item's temperature values in Celsius
public let celsius: (currentTemp: Double, maxTemp: Double, minTemp: Double)
/// Weather item's temperature values in Fahrenheit
public let fahrenheit: (currentTemp: Double, maxTemp: Double, minTemp: Double)

For example, if you want to get information on current weather in celsius you achieve that using following statement:

weatherItem.celsius.currentTemp

WeatherItem can be accessed from instances of ForecastItem. Here is example:

forecast.main.celsius.currentTemp

🛣 Roadmap

Please find project's roadmap below:

Version ETA Feature
✅ v0.1   January 2018 Current weather forecast by city & geo coordinates + support of different units (Celsius, Kelvin, Fahrenheit)
✅ v0.2 April 2018 Weather forecast for 5 days / 3 hour by city & geo coordinates.
v0.3 ??? 16 day daily forecast by city & geo coordinates.

⚠️ Support of other platforms (like watchOS, macOS & tvOS) will be introduced later