From 330427d21ae31fc450d6f302360fe523bfeae914 Mon Sep 17 00:00:00 2001 From: Evan Long Date: Mon, 19 Sep 2011 15:53:36 -0700 Subject: [PATCH] Making sure the success/failure callbacks for operationWithRequest are always called on the main thread. --- AFNetworking/AFJSONRequestOperation.m | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/AFNetworking/AFJSONRequestOperation.m b/AFNetworking/AFJSONRequestOperation.m index 0baabd8..364c334 100644 --- a/AFNetworking/AFJSONRequestOperation.m +++ b/AFNetworking/AFJSONRequestOperation.m @@ -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) {