CZWeatherKit

:partly_sunny: A Simple Cocoa Weather Library.

  • 所有者: comyar/CZWeatherKit
  • 平台:
  • 許可證: BSD 2-Clause "Simplified" License
  • 分類:
  • 主題:
  • 喜歡:
    0
      比較:

Github星跟蹤圖

Deprecated, consider using Jupiter instead.

Build Status
Version
Carthage compatible
Platform
License
git-brag-stats

CZWeatherKit is a simple, extensible weather library for iOS, tvOS, and OS X that allows for easy fetching of weather data from various weather services.

What's New in v2.2.7

Features
  • tvOS Support*.
  • Caching Support.
  • Support for historical and hourly data.
  • Request batching when using a weather service.
  • Improved request management when sending frequent requests.
  • Addition of more data, including humidity, wind speed, and more.

*Note: Features requiring MapKit are unsupported with tvOS.

Getting Started

CocoaPods

Add the following to your Podfile:

    pod "CZWeatherKit"

Usage

Included in this project is a Swift playground, CZWeatherKit.playground, that will let you play around with CZOpenWeatherMapRequest. However if you're as lazy as I am, here are some code snippets to get you started:

Wunderground

Getting Current Conditions, Obj-C
#import <CZWeatherKit/CZWeatherKit.h>

CZWundergroundRequest *request = [CZWundergroundRequest newConditionsRequest];
request.location = [CZWeatherLocation locationFromCity:@"Seattle" state:@"WA"];
request.key = @"wundergroundApiKey";
[request sendWithCompletion:^(CZWeatherData *data, NSError *error) {
	CZWeatherCurrentCondition *condition = data.current;
	// dreams come true here
}];
Getting Forecast Conditions, Swift
import CZWeatherKit

let request = CZWundergroundRequest.newForecastRequest()
request.location = CZWeatherLocation(fromCity: "Seattle", state: "WA")
request.key = "wundergroundApiKey"
request.sendWithCompletion { (data, error) -> Void in
    if let weather = data {
  		for forecast in weather.dailyForecasts {
  			// dreams come true here
  		}
    }
}

OpenWeatherMap

Getting Current Conditions, Obj-C
#import <CZWeatherKit/CZWeatherKit.h>

CZOpenWeatherMap *request = [CZOpenWeatherMapRequest newCurrentRequest];
request.location = [CZWeatherLocation locationFromCity:@"Seattle" state:@"WA"];
[request sendWithCompletion:^(CZWeatherData *data, NSError *error) {
	CZWeatherCurrentCondition *condition = data.current;
	// dreams come true here
}];
Getting Forecast Conditions, Swift
import CZWeatherKit

let request = CZOpenWeatherMapRequest.newDailyForecastRequestForDays(3)
request.location = CZWeatherLocation(fromCity: "Seattle", state: "WA")
request.sendWithCompletion { (data, error) -> Void in
    if let weather = data {
  		for forecast in weather.dailyForecasts {
  			// dreams come true here
  		}
    }
}

Using a Weather Service

A weather service allows for the dispatching of weather data requests and allows for more fine-grained control over how requests are handled as opposed to the interface provided by CZWeatherDataRequest. An ideal use case for a weather service is powering a weather app.

import CZWeatherKit

let service = CZWeatherService()
request = CZOpenWeatherMapRequest.newCurrentRequest()
request.location = CZWeatherLocation(fromCity: "Seattle", state: "WA")
service.dispatchRequest(request, completion: { (data, error) -> Void in
    if let weather = data {
        // dreams come true here
    }
})

Supported Weather APIs

CZWeatherKit currently supports the following weather services:

Climacons

CZWeatherKit supports Climacons out of the box. The Climacons Font is a font set created by Adam Whitcroft featuring weather icons.

Architecture, Core, Description, :--------, :------------, CZWeatherService, Asyncronously dispatches requests, caches responses, and simplifies key management when making frequent API calls., CZPINWeatherDataCache, An implementation of the CZWeatherDataCache protocol that uses PINCache for caching weather data., Model Type, Description, :--------, :------------, CZWeatherLocation, Represents a location to retrieve weather data for., CZWeatherData, Top-level container for all other weather data., CZWeatherCurrentCondition, Contains data for current conditions., CZWeatherForecastCondition, Contains data for a day's forecasted conditions., CZWeatherHourlyCondition, Contains data for an hour's conditions., CZWeatherRequest, The abstract base class for all request classes., CZWundergroundRequest, Used for calling the Wunderground API., CZOpenWeatherMapRequest, Used for calling the OpenWeatherMap API., CZForecastioRequest, Used for calling the Forecast.io API., CZWorldWeatherOnlineRequest, Used for calling the World Weather Online API., API Type, Description, :---, :-------------, CZWundergroundAPI, Wunderground API class., CZOpenWeatherMapAPI , OpenWeatherMap API class., CZForecastioAPI, Forecastio API class., CZWorldWeatherOnlineAPI, WorldWeatherOnline API class., Protocols, Description, :---, :-------------, CZWeatherAPI, The protocol for weather API classes., CZWeatherDataCache, The protocol for a cache used by a CZWeatherService., Headers, Description, :---, :-------------, CZClimacons, Contains mappings for Climacons to chars., CZWeatherKitTypes, Contains varions type definitions., # Contributing

If you would like to contribute to the development of CZWeatherKit, please take care to follow the style conventions and please include unit tests in your pull request.

For feature requests or general questions, feel free to post an issue.

Contributers

主要指標

概覽
名稱與所有者comyar/CZWeatherKit
主編程語言Objective-C
編程語言Objective-C (語言數: 4)
平台
許可證BSD 2-Clause "Simplified" License
所有者活动
創建於2014-05-19 17:05:11
推送於2024-08-06 00:41:40
最后一次提交
發布數22
最新版本名稱2.2.7 (發布於 )
第一版名稱0.5.0 (發布於 )
用户参与
星數448
關注者數22
派生數59
提交數287
已啟用問題?
問題數0
打開的問題數0
拉請求數13
打開的拉請求數0
關閉的拉請求數3
项目设置
已啟用Wiki?
已存檔?
是復刻?
已鎖定?
是鏡像?
是私有?