Created
October 24, 2012 06:30
-
-
Save gonzalezreal/3944391 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
- (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