TestsTested | ✓ |
LangLanguage | Obj-CObjective C |
License | MIT |
ReleasedLast Release | May 2016 |
Maintained by Nishanth Shanmugham.
A powerful API wrapper for Yahoo Weather for iOS and Mac. Built on top of AFNetworking’s blocks-based architecture, it fetches responses asynchronously without any waiting on the main thread.
This document provides a quick overview. Check out the full documentation.
The Yahoo Weather API does not require an API key.
Clone the repo and add all the files in the Pod/Classes
directory to your Xcode target.
#import <YWeatherAPI/YWeatherAPI.h>
Use the shared singleton to make requests:
[YWeatherAPI sharedManager];
Getting the current temperature is as simple as:
[[YWeatherAPI sharedManager] temperatureForLocation:@"Redwood City, California"
success:^(NSDictionary* result)
{
NSString* temperature = [result objectForKey:kYWAIndex];
NSLog(@"The temperature is a pleasant %@ F", temperature);
}
failure:^(id response, NSError* error)
{
// Yikes, something went wrong
}
];
The result in the success callback in the example is this NSDictionary object:
{
city = "Redwood City";
country = "United States";
index = 72; // key @"index" (the detail you asked for)
latitude = "37.5";
longitude = "-122.23";
region = CA;
temperatureInC = "22.22";
temperatureInF = 72;
}
See YWeatherAPI.h
for a complete list of keys and data types.
Customize the default weather units to be returned, enable caching of results, set the cache expiry duration, and more.
[YWeatherAPI sharedManager].defaultPressureUnit = MB;
[YWeatherAPI sharedManager].cacheEnabled = YES;
[YWeatherAPI sharedManager].cacheExpiryInMinutes = 10;
The full documentation is at CocoaDocs.
No, you do not. Yahoo Weather currently does not require an API key to access most of its content, so this API wrapper does not require one either. Please be respectful of this power.
The requirement for an API key may change in the future. If it does, care will be taken to follow semantic versioning rules for backwards compatibility.
Nope.
YWeatherAPI works on Mac OS X 10.8+ and iOS 6.0+.
master
branch. Yes, I too like to live dangerously.
YWeatherAPI is available under the MIT license. See the LICENSE file for more info.