Skip to content

Instantly share code, notes, and snippets.

@aaronpearce
Created October 21, 2011 07:36
Show Gist options
  • Save aaronpearce/1303303 to your computer and use it in GitHub Desktop.
Save aaronpearce/1303303 to your computer and use it in GitHub Desktop.
// Sets to allow into the block
__block APAppDelegate *appDele = (APAppDelegate *)[[UIApplication sharedApplication] delegate];
__block APMasterViewController *amvc = [appDele.navigationController topViewController];
id result = [appDele DiFiRequestWithURL:url];
// Runs a loop on the result looping through the responses
[[result valueForKey:@"response"] enumerateObjectsUsingBlock:^(id response, NSUInteger idx, BOOL *stop) {
// Checks if count is not 0?
if([[response valueForKeyPath:@"content.result.count"] objectAtIndex:0] != 0) {
// Loops through the hits from the query
[[[response valueForKeyPath:@"content.result.hits"] objectAtIndex:0] enumerateObjectsUsingBlock:^(id hit, NSUInteger idx, BOOL *stop) {
// Checks if there are hits
if([hit count] != 0) {
// add to the dataSet to be shown
[amvc.dataSet addObject:hit];
}
}];
}
// if stop is true, reload the table
if(stop)
[amvc.tableView reloadData];
}];
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment