SHOW:
|
|
- or go back to the newest paste.
1 | #import "TrendViewController.h" | |
2 | #import "CJSONDeserializer.h" | |
3 | #import "TweetSearchViewController.h" | |
4 | ||
5 | ||
6 | @implementation TrendViewController | |
7 | ||
8 | @synthesize trendArray = _trendArray; | |
9 | #pragma mark - | |
10 | #pragma mark View lifecycle | |
11 | ||
12 | #define kTwitterTrendURL @"http://api.twitter.com/1/trends/1.json" | |
13 | ||
14 | -(void)loadTrends{ | |
15 | NSURL *trendURL = [NSURL URLWithString:kTwitterTrendURL]; | |
16 | NSError* theError = nil; | |
17 | NSData *trendData = [NSData dataWithContentsOfURL:trendURL]; | |
18 | NSDictionary* jsonDict = [[CJSONDeserializer deserializer] | |
19 | deserializeAsDictionary:trendData error:&theError]; | |
20 | self.trendArray = [jsonDict objectForKey:@"trends"]; | |
21 | } | |
22 | ||
23 | ||
24 | - (void)viewDidLoad { | |
25 | [super viewDidLoad]; | |
26 | self.title=@"TwitterApp"; | |
27 | - | [self loadTrends]; |
27 | + | [self loadTrends]; |
28 | } |