@@ -7,38 +7,50 @@ from [openweathermap.org](http://openweathermap.org/ "OpenWeatherMap.org").
77
88### Installation ###
99
10- 1 . Include the header ` #import "OWMWeatherAPI.h" ` .
11- 2 . Setup the api:
10+ Using the API is really simple if you have [ CocoaPods] ( http://cocoapods.org/ " CocoaPods.org ") installed.
11+
12+ 1 . Add the dependency to your ` Podfile `
13+
14+ pod 'OpenWeatherMapAPI', '~ > 0.0.2'
15+
16+ 2 . Include the header ` #import "OWMWeatherAPI.h" ` .
17+ 3 . Setup the api:
1218
13- // Setup weather api
14- OWMWeatherAPI * weatherAPI = [[ OWMWeatherAPI alloc] initWithAPIKey:@"YOUR-API-KEY"] ;
19+ ``` Objective-c
20+ // Setup weather api
21+ OWMWeatherAPI *weatherAPI = [[OWMWeatherAPI alloc ] initWithAPIKey: @"YOUR-API-KEY"] ;
22+ ```
1523
24+ 4 . Select the default temperature format (defaults to Celcius)
1625
17- 3 . Select the default temperature format (defaults to Celcius)
26+ ``` Objective-c
1827 [weatherAPI setTemperatureFormat: kOWMTempCelcius] ;
19-
28+ ```
2029
2130### Getting data ###
2231
2332The api is at this time just simple wrapper for the http-api. So to get the current weather for
2433the city [ ` Odense ` ] ( http://en.wikipedia.org/wiki/Odense " Odense ") you can call it like this:
2534
26- [weatherAPI currentWeatherByCityName:@"Odense" withCallback:^(NSError *error, NSDictionary *result) {
27- if (error) {
28- // handle the error
29- return;
30- }
35+ ``` Objective-c
36+ [weatherAPI currentWeatherByCityName: @"Odense" withCallback:^(NSError * error, NSDictionary * result) {
37+ if (error) {
38+ // handle the error
39+ return;
40+ }
3141
32- // The data is ready
42+ // The data is ready
3343
34- NSString *cityName = result[@"name"];
35- NSNumber *currentTemp = result[@"main"][@"temp"];
44+ NSString *cityName = result[@"name"];
45+ NSNumber *currentTemp = result[@"main"][@"temp"];
3646
37- }]
47+ }]
48+ ```
3849
3950The result data is a `NSDictionary` that looks like
4051this ([json](http://api.openweathermap.org/data/2.5/weather?q=Odense "JSON data")):
41-
52+
53+ ```JavaScript
4254 {
4355 coord: {
4456 lon: 10.38831,
@@ -79,41 +91,45 @@ this ([json](http://api.openweathermap.org/data/2.5/weather?q=Odense "JSON data"
7991 name: "Odense",
8092 cod: 200
8193 }
94+ ```
8295
8396See an example in the ` OWMViewController.m ` file.
8497
8598## Methods ##
8699The following methods are availabe at this time:
87100
88101current weather by city name:
89-
102+ ``` Objective-c
90103 -(void ) currentWeatherByCityName:(NSString *) name
91104 withCallback:( void (^)( NSError * error, NSDictionary *result ) )callback;
92-
105+ ```
93106
94107current weather by coordinate:
95-
108+ ``` Objective-c
96109 -(void ) currentWeatherByCoordinate:(CLLocationCoordinate2D) coordinate
97110 withCallback:( void (^)( NSError * error, NSDictionary *result ) )callback;
111+ ```
98112
99113current weather by city id:
100-
114+ ``` Objective-c
101115 -(void ) currentWeatherByCityId:(NSString *) cityId
102116 withCallback:( void (^)( NSError * error, NSDictionary *result ) )callback;
103-
117+ ```
104118
105119forcast by city name:
106-
120+ ``` Objective-c
107121 -(void ) forecastWeatherByCityName:(NSString *) name
108122 withCallback:( void (^)( NSError * error, NSDictionary *result ) )callback;
123+ ```
109124
110125forcast by coordinate:
111-
126+ ``` Objective-c
112127 -(void ) forecastWeatherByCoordinate:(CLLocationCoordinate2D) coordinate
113128 withCallback:( void (^)( NSError * error, NSDictionary *result ) )callback;
129+ ```
114130
115131forcast by city id:
116-
132+ ``` Objective-c
117133 -(void ) forecastWeatherByCityId:(NSString *) cityId
118134 withCallback:( void (^)( NSError * error, NSDictionary *result ) )callback;
119-
135+ ```
0 commit comments