OpenWeatherFreeClient — Xcode 10.1+
OpenWeatherMap Free API Client released as the component for both macOS and iOS apps as well.
Integration Capabilities
In Brief
This library lets a developer perform the network calls requesting weather data available for free with
OpenWeather API
. It contains the implementation ofCurrent Weather Data
and5 Day / 3 Hour Forecast
of the API.
Individual API key
is required.
Requirements
- macOS 10.13.6+
- Xcode 10.1+
- Swift 4.2+
- iOS: 9.3+, UIKit SDK
- macOS: 10.9+, AppKit SDK
First-party software
Third-party software
- SwiftLint Shell Script Runner
- SwiftLint / 0.31.0: Busy Laundromat for macOS High Sierra
Installation
Using "Exact" with the Version field is strongly recommended.
Standalone
Make a copy of the file OpenWeatherStar.swift
then put it into a place required of a host project.
Carthage
Cartfile should contain:
github "perseusrealdeal/OpenWeatherFreeClient" == 0.1.1
Some Carthage usage tips placed here.
CocoaPods
Podfile should contain:
target "ProjectTarget" do
use_frameworks!
pod 'OpenWeatherFreeClient', '0.1.1'
end
Swift Package Manager
- As a package dependency so Package.swift should contain the following statements:
dependencies: [
.package(url: "https://github.com/perseusrealdeal/OpenWeatherFreeClient.git",
.exact("0.1.1"))
],
- As an Xcode project dependency:
Project in the Navigator > Package Dependencies > Add Package Dependency
Using "Exact" with the Version field is strongly recommended.
Usage
Call Current Weather
let apikey = "The API key"
let client = OpenWeatherFreeClient()
let callDetails = OpenWeatherDetails(appid: apikey)
client.onDataGiven = { result in
switch result {
case .success(let weatherData):
print("""
DATA: BEGIN
\(String(decoding: weatherData, as: UTF8.self))
DATA: END
""")
case .failure(let error):
switch error {
case .failedRequest(let message):
print(message)
default:
break
}
}
}
try? client.call(with: callDetails)
Call 5 Day / 3 Hour Forecast
let apikey = "The API key"
let client = OpenWeatherFreeClient()
let callDetails = OpenWeatherDetails(appid: apikey, format: .forecast)
client.onDataGiven = { result in
switch result {
case .success(let weatherData):
print("""
DATA: BEGIN
\(String(decoding: weatherData, as: UTF8.self))
DATA: END
""")
case .failure(let error):
switch error {
case .failedRequest(let message):
print(message)
default:
break
}
}
}
try? client.call(with: callDetails)
License MIT
All files from this repository is under license based on MIT.
Copyright © 7531 Mikhail Zhigulin of Novosibirsk.
- The year starts from the creation of the world according to a Slavic calendar
- September, the 1st of Slavic year
LICENSE for details.
Author
OpenWeatherFreeClient
was written at Novosibirsk by Mikhail Zhigulin i.e. me, [email protected].