Fixing default implementation of AFHTTPRequestOperation +HTTPRequestOperationWithRequest:success:failure: not return nil

This commit is contained in:
Mattt Thompson 2011-10-24 09:48:19 -05:00
parent 1ba0d22b45
commit 8007f0aade

View file

@ -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