Skip to content

AlvaroFranco/AFWeather

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

8 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

AFWeather

Build Status alt text alt text alt text

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.

alt text

##Installation

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

##Services supported

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

##Usage

First of all, make sure that you have imported the main class into the class where you are going to get the weather information.

#import "AFWeather.h"

###Configuring the client

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"];

###Getting the forecast from a city name or Zip code

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
        }
    }];

###Getting the forecast from the coordinates

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
        }
    }];

##License AFWeather is under MIT license so feel free to use it!

##Author Made by Alvaro Franco. If you have any question, feel free to drop me a line at alvarofrancoayala@gmail.com