Skip to content

Instantly share code, notes, and snippets.

@gonzalezreal
Created October 24, 2012 06:30
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save gonzalezreal/3944391 to your computer and use it in GitHub Desktop.
Save gonzalezreal/3944391 to your computer and use it in GitHub Desktop.
- (void)loadTweetsWithRequest:(SLRequest *)request completionHandler:(void (^)(NSError *error))completionHandler
{
self.loading = YES;
[request performRequestWithHandler:^(NSData *responseData, NSHTTPURLResponse *urlResponse, NSError *error) {
if (!error) {
id response = [NSJSONSerialization JSONObjectWithData:responseData
options:0
error:NULL];
if ([response isKindOfClass:[NSArray class]]) {
[self.managedObjectContext performBlock:^{
[self importTweets:response];
}];
}
else {
NSLog(@"Error: %@", response[@"errors"][0][@"message"]);
}
}
dispatch_async(dispatch_get_main_queue(), ^{
self.loading = NO;
completionHandler(error);
});
}];
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment