Skip to content

Instantly share code, notes, and snippets.

@mmesarina
Created October 18, 2014 04:19
Show Gist options
  • Select an option

  • Save mmesarina/ed2643f4ebcfdbb3ea25 to your computer and use it in GitHub Desktop.

Select an option

Save mmesarina/ed2643f4ebcfdbb3ea25 to your computer and use it in GitHub Desktop.
RottenTomatoes ViewDidLoad of MoviesTableViewController
- (void)viewDidLoad {
[super viewDidLoad];
NSString *url = @"http://api.rottentomatoes.com/api/public/v1.0/lists/movies/in_theaters.json?apikey=ws32mxpd653h5c8zqfvksxw9";
NSURLRequest *request = [NSURLRequest requestWithURL:[NSURL URLWithString:url]];
[NSURLConnection sendAsynchronousRequest:request queue:[NSOperationQueue mainQueue] completionHandler:^(NSURLResponse *response, NSData *data, NSError *connectionError) {
id object = [NSJSONSerialization JSONObjectWithData:data options:0 error:nil];
// NSLog(@"%@", object);
self.movies = object[@"movies"];
[self.tableView reloadData];
}];
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment