Skip to content

Commit

Permalink
Fixing default implementation of AFHTTPRequestOperation +HTTPRequestO…
Browse files Browse the repository at this point in the history
…perationWithRequest:success:failure: not return nil
  • Loading branch information
mattt committed Oct 24, 2011
1 parent 1ba0d22 commit 8007f0a
Showing 1 changed file with 22 additions and 1 deletion.
23 changes: 22 additions & 1 deletion AFNetworking/AFHTTPRequestOperation.m
Expand Up @@ -96,7 +96,28 @@ + (AFHTTPRequestOperation *)HTTPRequestOperationWithRequest:(NSURLRequest *)urlR
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

0 comments on commit 8007f0a

Please sign in to comment.