Don't execute completion block if cancelled
This commit is contained in:
parent
561df45eb7
commit
b85c59516d
3 changed files with 13 additions and 1 deletions
|
|
@ -38,6 +38,10 @@
|
|||
{
|
||||
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) {
|
||||
|
|
|
|||
|
|
@ -53,6 +53,10 @@ static dispatch_queue_t image_request_operation_processing_queue() {
|
|||
AFImageRequestOperation *operation = [[[AFImageRequestOperation alloc] initWithRequest:urlRequest] autorelease];
|
||||
|
||||
operation.completionBlock = ^ {
|
||||
if ([operation isCancelled]) {
|
||||
return;
|
||||
}
|
||||
|
||||
dispatch_async(image_request_operation_processing_queue(), ^(void) {
|
||||
if (operation.error) {
|
||||
if (failure) {
|
||||
|
|
|
|||
|
|
@ -274,6 +274,10 @@ static inline BOOL AFOperationStateTransitionIsValid(AFOperationState from, AFOp
|
|||
}
|
||||
|
||||
- (void)cancel {
|
||||
if ([self isFinished]) {
|
||||
return;
|
||||
}
|
||||
|
||||
[super cancel];
|
||||
|
||||
self.cancelled = YES;
|
||||
|
|
@ -282,7 +286,7 @@ static inline BOOL AFOperationStateTransitionIsValid(AFOperationState from, AFOp
|
|||
}
|
||||
|
||||
- (void)finish {
|
||||
self.state = AFHTTPOperationFinishedState;
|
||||
self.state = AFHTTPOperationFinishedState;
|
||||
}
|
||||
|
||||
#pragma mark - NSURLConnectionDelegate
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue