From 8007f0aade8172ee60476c08ea64bf2b58367478 Mon Sep 17 00:00:00 2001 From: Mattt Thompson Date: Mon, 24 Oct 2011 09:48:19 -0500 Subject: [PATCH] Fixing default implementation of AFHTTPRequestOperation +HTTPRequestOperationWithRequest:success:failure: not return nil --- AFNetworking/AFHTTPRequestOperation.m | 23 ++++++++++++++++++++++- 1 file changed, 22 insertions(+), 1 deletion(-) diff --git a/AFNetworking/AFHTTPRequestOperation.m b/AFNetworking/AFHTTPRequestOperation.m index 571d918..b7d72a3 100644 --- a/AFNetworking/AFHTTPRequestOperation.m +++ b/AFNetworking/AFHTTPRequestOperation.m @@ -96,7 +96,28 @@ success:(void (^)(id object))success failure:(void (^)(NSHTTPURLResponse *response, NSError *error))failure { - return nil; + AFHTTPRequestOperation *operation = [[[self alloc] initWithRequest:urlRequest] autorelease]; + operation.completionBlock = ^ { + if ([operation isCancelled]) { + return; + } + + if (operation.error) { + if (failure) { + dispatch_async(dispatch_get_main_queue(), ^(void) { + failure(operation.response, operation.error); + }); + } + } else { + if (success) { + dispatch_async(dispatch_get_main_queue(), ^(void) { + success(operation.responseData); + }); + } + } + }; + + return operation; } @end