Created
July 23, 2012 13:37
-
-
Save pita5/3163637 to your computer and use it in GitHub Desktop.
This file contains hidden or 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)_updateEntries:(void (^)(void))block forEvent:(SKEvent *)event caller:(dispatch_queue_t)callerqueue | |
{ | |
void(^block_c)(void) = ^(void) { | |
NSLog(@"completed update entries for %@", event.uid); | |
if (block) block(); | |
}; | |
// Fail early if no event | |
if (!event) | |
{ | |
[self _didFailUpdateEntries:block_c forEvent:event caller:callerqueue]; | |
return; | |
} | |
NSURLResponse* __autoreleasing response = nil; | |
NSError* __autoreleasing responseError = nil; | |
NSURL* url = [NSURL URLWithString:[NSString stringWithFormat:@"%@%@",kSKEntriesFormat,event.actid]]; | |
NSData* responseData = [NSURLConnection sendSynchronousRequest:[NSURLRequest requestWithURL:url] returningResponse:&response error:&responseError]; | |
if (!responseData || responseError) | |
{ | |
[self _didFailUpdateEntries:block_c forEvent:event caller:callerqueue]; | |
return; | |
} | |
NSError* __autoreleasing jsonError = nil; | |
NSDictionary* baseDictionary = [NSJSONSerialization JSONObjectWithData:responseData options:NSJSONReadingAllowFragments error:&jsonError]; | |
if (!baseDictionary || jsonError) | |
{ | |
[self _didFailUpdateEntries:block_c forEvent:event caller:callerqueue]; | |
return; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment