Skip to content

Commit

Permalink
Ensure the response is retained before a background thread is kicked off
Browse files Browse the repository at this point in the history
  • Loading branch information
keithpitt committed Aug 28, 2011
1 parent f5a8cf1 commit e0dffdd
Showing 1 changed file with 12 additions and 1 deletion.
13 changes: 12 additions & 1 deletion Classes/DKAPIRequest.m
Expand Up @@ -221,16 +221,27 @@ - (void)requestFinished:(ASIHTTPRequest *)request {

// Finish by calling our block
// Only pass in the response if there are no errors
if (finishBlock)
if (finishBlock) {

// Retain the response for use in the thread
[response retain];

// Run the finish block in a background therad
dispatch_async(currentDispatchQueue, ^{
if (response.error)
finishBlock(nil, response.error);
else
finishBlock(response, nil);

// Release the response
[response release];
});

}

}

// Release the response
[response release];

// Release the reference to self we made earlier
Expand Down

0 comments on commit e0dffdd

Please sign in to comment.