Skip to content

souhl/CZWeatherKit

 
 

Repository files navigation

Build Status License

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

What's New in v2.0

Features
  • New architecture.
  • Support for historical and hourly data, Issue #14.
  • Addition of more data, including humidity, wind speed, and more.
Bug Fixes
  • Overall improved testing
  • Improved JSON parsing, Issue #16.
  • Fixed issue where Climacons were only correct for English language data, Issue #12.
What's next?
  • Better support for use cases that require frequent requests (i.e. like a weather app)
  • Built-in caching support

Getting Started

Cocoa Pods

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 locationForCity:@"Seattle" state:@"WA"];
request.key = @"wundergroundApiKey";
[request sendWithCompletion:^(CZWeatherData *data, NSError *error) {
	CZWeatherCurrentCondition *condition = date.current;
	// dreams come true here
}];
Getting Forecast Conditions, Swift
import CZWeatherKit

let request = CZWundergroundRequest.newForecastRequest()
request.location = CZWeatherLocation(fromCity: "Seattle", country: "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 locationForCity:@"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", country: "WA")
request.sendWithCompletion { (data, error) -> Void in
    if let weather = data {
  		for forecast in weather.dailyForecasts {
  			// 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

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

About

A Simple Cocoa Weather Library.

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages

  • Objective-C 95.1%
  • C 2.9%
  • Swift 1.6%
  • Ruby 0.4%