Skip to content

Instantly share code, notes, and snippets.

Created December 13, 2012 16:18
Show Gist options
  • Save anonymous/4277562 to your computer and use it in GitHub Desktop.
Save anonymous/4277562 to your computer and use it in GitHub Desktop.
AFJSONRequestOperation *operationJSON = [AFJSONRequestOperation
JSONRequestOperationWithRequest:requestJSON
success:^(NSURLRequest *request, NSHTTPURLResponse *response, id JSON) {
NSMutableArray *results = [JSON valueForKey:@"results"];
// UPDATED CODE
for (id obj in [results valueForKey:@"value"]) {
if (![items containsObject:obj]) {
[items addObject:obj];
}
}
for (id obj2 in [results valueForKey:@"value2"]) {
if (![items2 containsObject:obj2]) {
[items2 addObject:obj2];
}
}
// END OF UPDATED CODE
/**
AFJSONOperation dispatches work to background thread. UIKit is not thread-safe . So dispatching work to main queue.
*/
dispatch_async(dispatch_get_main_queue(),^{
[table reloadData];
[table scrollRectToVisible:CGRectMake(0, 0, 1, 1) animated:YES];
[table.pullToRefreshView stopAnimating];
});
}
failure:^(NSURLRequest *request, NSHTTPURLResponse *response, NSError *error, id JSON) {
NSLog(@"%@", [error userInfo]);
}];
[operationJSON start];
[table reloadData];
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment