Skip to content

Instantly share code, notes, and snippets.

@jsooriah
Created May 9, 2014 09:07
Show Gist options
  • Save jsooriah/361913485ed9936c5a68 to your computer and use it in GitHub Desktop.
Save jsooriah/361913485ed9936c5a68 to your computer and use it in GitHub Desktop.
- (NSArray *)fetchPopularSearches {
__block NSMutableArray *result = [NSMutableArray array];
NSString *searchQuery = [NSString stringWithFormat:@"url_to_flights_json"];
NSURL *url = [[NSURL alloc] initWithString:searchQuery];
NSURLRequest *request = [[NSURLRequest alloc] initWithURL:url];
AFJSONRequestOperation *operation = [AFJSONRequestOperation JSONRequestOperationWithRequest:request
success:^(NSURLRequest *request, NSHTTPURLResponse *response, id JSON)
{
// build flights array
// reload uitableview data
[self.searchTableView reloadData];
} failure:^(NSURLRequest *request, NSHTTPURLResponse *response, NSError *error, id JSON) {
}];
[operation start];
return result;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment