TestsTested | ✗ |
LangLanguage | Obj-CObjective C |
License | MIT |
ReleasedLast Release | Mar 2015 |
Maintained by Alvaro Franco.
Getting the weather forecast never has been so easy and it supports 5 different services. It returns the raw json so you can easily get the data you need.
AFWeather is available on CocoaPods so you can get it by adding this line to your Podfile:
pod 'AFWeather', '~> 1.0'
If you don't use CocoaPods, you will have to import these files into your project:
AFWeather.h
AFWeather.m
Service name | Place name/Zip code | Coordinates | AFWeather name |
---|---|---|---|
World Weather Online | ![]() |
![]() |
AFWeatherAPIWorldWeatherOnline |
Weather Undeground | ![]() |
![]() |
AFWeatherAPIWeatherUnderground |
Open Weather Map | ![]() |
![]() |
AFWeatherAPIOpenWeatherMap |
AccuWeather | ![]() |
![]() |
AFWeatherAPIAccuWeather |
Forecast.io | ![]() |
![]() |
AFWeatherAPIForecast |
First of all, make sure that you have imported the main class into the class where you are going to play audio.
#import "AFWeather.h"
In order to make AFWeather know what service are you using and what's your API key, use the method -configureClientWithService:withAPIKey:
. Example:
[[AFWeather sharedClient]configureClientWithService:AFWeatherAPIForecast withAPIKey:@"myawesomeapikey"];
For this, use -fetchForecastOfLocationWithName:andCompletionBlock:
Example:
[[AFWeather sharedClient]fetchForecastOfLocationWithName:@"Murcia" andCompletionBlock:^(NSDictionary *response, NSError *error) {
if (!error) {
// Handle the response dictionary with all the information
} else {
//Handle the error
}
}];
You can also use the latitude and the longitude instead of the place name.
[[AFWeather sharedClient]fetchForecastOfLocationWithLatitude:@"121.518446" andLogitude:@"-26.181156" andCompletionBlock:^(NSDictionary *response, NSError *error) {
if (!error) {
// Handle the response dictionary with all the information
} else {
//Handle the error
}
}];
AFWeather is under MIT license so feel free to use it!
Made by Alvaro Franco. If you have any question, feel free to drop me a line at [email protected]