Latest 0.8.11
Homepage https://github.com/MendyK/MKWeatherUndergroundKit
License MIT
Platforms ios 8.0, requires ARC
Frameworks CoreLocation
Authors

A simple iOS and OS X library for retrieving weather information using the Weather Underground API

Getting Started

You’ll need a Weather Underground API key to start.

Getting the Current Conditions

    //Get the location
    CLGeocoder *geocoder = [CLGeocoder new];
    [geocoder geocodeAddressString:@"New York" completionHandler:^(NSArray *placemarks, NSError *error) {
        CLPlacemark *placemark = [placemarks firstObject];

        //Initialize request
        MKWeatherRequest *request = [MKWeatherRequest requestWithType:MKWeatherRequestTypeCurrentConditions
                                                             location:placemark.location];
        request.weatherUndergroundApiKey = @"API_KEY_HERE";
        [request performRequestWithHandler:^(NSError *error, id responseObject) {
            MKWeatherCondition *currentConditions = responseObject;
            //Use currentConditions object here
        }];
    }];

Getting the forecast for the next 36 hours

    CLGeocoder *geocoder = [CLGeocoder new];
    [geocoder geocodeAddressString:@"San Francisco" completionHandler:^(NSArray *placemarks, NSError *error) {
        CLPlacemark *placemark = [placemarks firstObject];

        MKWeatherRequest *request = [MKWeatherRequest requestWithType:MKWeatherRequestTypeHourly
                                                             location:placemark.location];
        request.weatherUndergroundApiKey = @"API_KEY_HERE";
        [request performRequestWithHandler:^(NSError *error, id responseObject) {
            NSArray *hours = responseObject;
            //Array of MKWeatherCondition Objects
        }];
    }];

Getting the forecast for the next 3 days

    CLGeocoder *geocoder = [CLGeocoder new];
    [geocoder geocodeAddressString:@"London, England" completionHandler:^(NSArray *placemarks, NSError *error)     {
        CLPlacemark *placemark = [placemarks firstObject];

        MKWeatherRequest *request = [MKWeatherRequest requestWithType:MKWeatherRequestType3DayForecast
                                                             location:placemark.location];
        request.weatherUndergroundApiKey = @"API_KEY_HERE";
        [request performRequestWithHandler:^(NSError *error, id responseObject) {
            NSArray *threeDayForecast = responseObject;
            //Here responseObject is an array that contains 4 objects: tonight, and the next three days.

            MKWeatherCondition *tonightsConditions = [threeDayForecast firstObject];

            NSLog(@"%f", tonightsConditions.highTemp.c);
            NSLog(@"%f", tonightsConditions.lowTemp.c);
            NSLog(@"%ld", (long)tonightsConditions.averageHumudity);

        }];
    }];

Getting a small forecast summary for the next 3 days

    CLGeocoder *geocoder = [CLGeocoder new];
    [geocoder geocodeAddressString:@"New Mexico" completionHandler:^(NSArray *placemarks, NSError *error)     {
        CLPlacemark *placemark = [placemarks firstObject];

        MKWeatherRequest *request = [MKWeatherRequest requestWithType:MKWeatherRequestType3DayForecastSummary
                                                             location:placemark.location];
        request.weatherUndergroundApiKey = @"API_KEY_HERE";
        [request performRequestWithHandler:^(NSError *error, id responseObject) {
            NSArray *threeDayForecast = responseObject;
            //Here responseObject is an array which contains 8 objects

            MKWeatherCondition *condition = [threeDayForecast firstObject];
            NSLog(@"%@", condition.generalTimeOfDayTitle);
            NSLog(@"%@", condition.fullSummaryC);
            NSLog(@"%@", condition.fullSummaryF);

        }];
    }];

Climacons

MKWeatherCondition objects have a climacon property that contains an appropriate climacon character mapping for the weather condition description. The Climacons Font is a font set created by Adam Whitcroft featuring various weather-related icons. In order to use the climacon property, download the Climacons font and add it to your project.

Dependencies

This library uses Core Location to perform requests.

Architecture

MKWeatherCondition – A generic weather condition

MKWeatherParser – Parses the weather information received from the Weather Underground API

MKWeatherRequest – Represents a single request to the Weather Underground API

CocoaPods

To use this with CocoaPods, add pod 'MKWeatherUndergroundKit' to your podfile

Thanks

Kevin Mindeguia for the NSDictionary/NSArray categories.

Comyar Zaheri for the Climacons.h file and the Climacons description.

License

See the License file

Latest podspec

{
    "name": "MKWeatherUndergroundKit",
    "version": "0.8.11",
    "summary": "A simple iOS and OS X library for retrieving weather information using the Weather Underground API",
    "homepage": "https://github.com/MendyK/MKWeatherUndergroundKit",
    "license": {
        "type": "MIT",
        "file": "LICENSE"
    },
    "authors": {
        "Mendy Krinsky": "[email protected]"
    },
    "social_media_url": "https://twitter.com/MenndK",
    "platforms": {
        "ios": "8.0"
    },
    "source": {
        "git": "https://github.com/MendyK/MKWeatherUndergroundKit.git",
        "tag": "v0.8.11"
    },
    "source_files": "MKWeatherUndergroundKit/*.{h,m}",
    "resources": "MKWeatherUndergroundKit/Climacons.ttf",
    "requires_arc": true,
    "frameworks": "CoreLocation"
}

Pin It on Pinterest

Share This