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.
YWeatherAPI is available through CocoaPods. To install it, simply add the following line to your Podfile:
pod 'YWeatherAPI'And then from terminal, run:
$ pod installClone 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;- Caching results, with customizable cache expiry times.
- Looking up weather data by CLLocation, natural-language location string, and Yahoo WOEID.
- Looking up weather data in customizable pressure, distance, speed, and temperature units.
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+.
- CoreLocation is required to reverse geocode coordinates.
- AFNetworking ~>2.0 is a dependency and is automatically installed along with YWeatherAPI if it isn't already.
- New features, bug fixes, and additional documentation and tests are welcome! Please fork the repository and request to be merged into the
masterbranch. Yes, I too like to live dangerously. - Alternatively, if you have a feature request or find a bug, please let me know here, on Twitter, or email.
YWeatherAPI is available under the MIT license. See the LICENSE file for more info.