From 800d05181deaa18506c26231b145f0a448b44a25 Mon Sep 17 00:00:00 2001 From: Peter Steinberger Date: Wed, 8 Feb 2012 15:04:29 -0800 Subject: [PATCH] Simplify dispatchFailureBlock As error is overridden to always return the custom error object we can omit the extra error: parameter in dispatchFailureBlock, making the code even simpler. --- AFNetworking/AFHTTPRequestOperation.h | 2 +- AFNetworking/AFHTTPRequestOperation.m | 7 +++---- AFNetworking/AFImageRequestOperation.m | 2 +- AFNetworking/AFJSONRequestOperation.m | 2 +- AFNetworking/AFPropertyListRequestOperation.m | 4 ++-- AFNetworking/AFXMLRequestOperation.m | 2 +- 6 files changed, 9 insertions(+), 10 deletions(-) diff --git a/AFNetworking/AFHTTPRequestOperation.h b/AFNetworking/AFHTTPRequestOperation.h index 7c3d234..ea6bfd0 100644 --- a/AFNetworking/AFHTTPRequestOperation.h +++ b/AFNetworking/AFHTTPRequestOperation.h @@ -119,6 +119,6 @@ /** Executes the failureBlock on the corresponding failureCallbackQueue. */ -- (void)dispatchFailureBlock:(void (^)(AFHTTPRequestOperation *operation, NSError *error))failureBlock error:(NSError *)error; +- (void)dispatchFailureBlock:(void (^)(AFHTTPRequestOperation *operation, NSError *error))failureBlock; @end \ No newline at end of file diff --git a/AFNetworking/AFHTTPRequestOperation.m b/AFNetworking/AFHTTPRequestOperation.m index 6f72918..591c56e 100644 --- a/AFNetworking/AFHTTPRequestOperation.m +++ b/AFNetworking/AFHTTPRequestOperation.m @@ -127,7 +127,7 @@ } if (self.error) { - [self dispatchFailureBlock:failure error:self.error]; + [self dispatchFailureBlock:failure]; } else { [self dispatchSuccessBlock:success responseObject:self.responseString]; } @@ -150,12 +150,11 @@ } } -- (void)dispatchFailureBlock:(void (^)(AFHTTPRequestOperation *operation, NSError *error))failureBlock error:(NSError *)error { +- (void)dispatchFailureBlock:(void (^)(AFHTTPRequestOperation *operation, NSError *error))failureBlock { if (failureBlock) { dispatch_async(self.failureCallbackQueue ? self.failureCallbackQueue : dispatch_get_main_queue(), ^{ - failureBlock(self, error); + failureBlock(self, self.error); }); - } } diff --git a/AFNetworking/AFImageRequestOperation.m b/AFNetworking/AFImageRequestOperation.m index 554f6b7..091f571 100644 --- a/AFNetworking/AFImageRequestOperation.m +++ b/AFNetworking/AFImageRequestOperation.m @@ -230,7 +230,7 @@ static dispatch_queue_t image_request_operation_processing_queue() { dispatch_async(image_request_operation_processing_queue(), ^(void) { if (self.error) { - [self dispatchFailureBlock:failure error:self.error]; + [self dispatchFailureBlock:failure]; } else { [self dispatchSuccessBlock:success responseObject:self.responseImage]; } diff --git a/AFNetworking/AFJSONRequestOperation.m b/AFNetworking/AFJSONRequestOperation.m index 07e6113..13bfd74 100644 --- a/AFNetworking/AFJSONRequestOperation.m +++ b/AFNetworking/AFJSONRequestOperation.m @@ -134,7 +134,7 @@ static dispatch_queue_t json_request_operation_processing_queue() { id JSON = self.responseJSON; if (self.JSONError) { - [self dispatchFailureBlock:failure error:self.JSONError]; + [self dispatchFailureBlock:failure]; } else { [self dispatchSuccessBlock:success responseObject:JSON]; } diff --git a/AFNetworking/AFPropertyListRequestOperation.m b/AFNetworking/AFPropertyListRequestOperation.m index b65692e..d294cd2 100644 --- a/AFNetworking/AFPropertyListRequestOperation.m +++ b/AFNetworking/AFPropertyListRequestOperation.m @@ -124,13 +124,13 @@ static dispatch_queue_t property_list_request_operation_processing_queue() { } if (self.error) { - [self dispatchFailureBlock:failure error:self.error]; + [self dispatchFailureBlock:failure]; } else { dispatch_async(property_list_request_operation_processing_queue(), ^(void) { id propertyList = self.responsePropertyList; if (self.propertyListError) { - [self dispatchFailureBlock:failure error:self.propertyListError]; + [self dispatchFailureBlock:failure]; }else { [self dispatchSuccessBlock:success responseObject:propertyList]; } diff --git a/AFNetworking/AFXMLRequestOperation.m b/AFNetworking/AFXMLRequestOperation.m index f3966c4..7b50fd6 100644 --- a/AFNetworking/AFXMLRequestOperation.m +++ b/AFNetworking/AFXMLRequestOperation.m @@ -187,7 +187,7 @@ static dispatch_queue_t xml_request_operation_processing_queue() { } if (self.error) { - [self dispatchFailureBlock:failure error:self.error]; + [self dispatchFailureBlock:failure]; } else { [self dispatchSuccessBlock:success responseObject:self.responseXMLParser]; }