Fixing default implementation of AFHTTPRequestOperation +HTTPRequestOperationWithRequest:success:failure: not return nil
This commit is contained in:
parent
1ba0d22b45
commit
8007f0aade
1 changed files with 22 additions and 1 deletions
|
|
@ -96,7 +96,28 @@
|
||||||
success:(void (^)(id object))success
|
success:(void (^)(id object))success
|
||||||
failure:(void (^)(NSHTTPURLResponse *response, NSError *error))failure
|
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
|
@end
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue