From 1bab351997efb6fde38dc542b6caa4dd8f04a4f5 Mon Sep 17 00:00:00 2001 From: Kevin Harwood Date: Wed, 29 Feb 2012 11:57:54 -0600 Subject: [PATCH] Moved nil'ing the connection until after the delegate is called --- AFNetworking/AFURLConnectionOperation.m | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/AFNetworking/AFURLConnectionOperation.m b/AFNetworking/AFURLConnectionOperation.m index 2ad446d..6600d77 100644 --- a/AFNetworking/AFURLConnectionOperation.m +++ b/AFNetworking/AFURLConnectionOperation.m @@ -351,11 +351,12 @@ static inline BOOL AFStateTransitionIsValid(AFOperationState fromState, AFOperat - (void)cancelConnection { if (self.connection) { [self.connection cancel]; - self.connection = nil; // Manually send this delegate message since `[self.connection cancel]` causes the connection to never send another message to its delegate NSDictionary *userInfo = [NSDictionary dictionaryWithObject:[self.request URL] forKey:NSURLErrorFailingURLErrorKey]; [self performSelector:@selector(connection:didFailWithError:) withObject:self.connection withObject:[NSError errorWithDomain:NSURLErrorDomain code:NSURLErrorCancelled userInfo:userInfo]]; + + self.connection = nil; } }