
Untitled
By: a guest on
Sep 16th, 2012 | syntax:
None | size: 1.24 KB | hits: 7 | expires: Never
- (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;
}
}