Skip to content

Commit

Permalink
Making sure the success/failure callbacks for operationWithRequest ar…
Browse files Browse the repository at this point in the history
…e always

called on the main thread.
  • Loading branch information
Evan Long committed Sep 19, 2011
1 parent 29ace55 commit 330427d
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions AFNetworking/AFJSONRequestOperation.m
Original file line number Diff line number Diff line change
Expand Up @@ -84,11 +84,15 @@ + (id)operationWithRequest:(NSURLRequest *)urlRequest

if (error) {
if (failure) {
failure(request, response, error);
dispatch_async(dispatch_get_main_queue(), ^{
failure(request, response, error);
});
}
} else if ([data length] == 0) {
if (success) {
success(request, response, nil);
dispatch_async(dispatch_get_main_queue(), ^{
success(request, response, nil);
});
}
} else {
dispatch_async(json_request_operation_processing_queue(), ^(void) {
Expand Down

0 comments on commit 330427d

Please sign in to comment.