Created
December 13, 2012 16:18
-
-
Save anonymous/4277562 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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