Skip to content
This repository was archived by the owner on Mar 22, 2019. It is now read-only.

Commit c2cbe8f

Browse files
committed
Updated the README with pod info and syntaxhighlighting
1 parent 39befee commit c2cbe8f

File tree

1 file changed

+41
-25
lines changed

1 file changed

+41
-25
lines changed

README.md

Lines changed: 41 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -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

2332
The api is at this time just simple wrapper for the http-api. So to get the current weather for
2433
the 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
3950
The result data is a `NSDictionary` that looks like
4051
this ([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

8396
See an example in the `OWMViewController.m` file.
8497

8598
## Methods ##
8699
The following methods are availabe at this time:
87100

88101
current weather by city name:
89-
102+
```Objective-c
90103
-(void) currentWeatherByCityName:(NSString *) name
91104
withCallback:( void (^)( NSError* error, NSDictionary *result ) )callback;
92-
105+
```
93106

94107
current weather by coordinate:
95-
108+
```Objective-c
96109
-(void) currentWeatherByCoordinate:(CLLocationCoordinate2D) coordinate
97110
withCallback:( void (^)( NSError* error, NSDictionary *result ) )callback;
111+
```
98112

99113
current weather by city id:
100-
114+
```Objective-c
101115
-(void) currentWeatherByCityId:(NSString *) cityId
102116
withCallback:( void (^)( NSError* error, NSDictionary *result ) )callback;
103-
117+
```
104118

105119
forcast by city name:
106-
120+
```Objective-c
107121
-(void) forecastWeatherByCityName:(NSString *) name
108122
withCallback:( void (^)( NSError* error, NSDictionary *result ) )callback;
123+
```
109124

110125
forcast by coordinate:
111-
126+
```Objective-c
112127
-(void) forecastWeatherByCoordinate:(CLLocationCoordinate2D) coordinate
113128
withCallback:( void (^)( NSError* error, NSDictionary *result ) )callback;
129+
```
114130

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

Comments
 (0)