Skip to content

Commit

Permalink
Moved nil'ing the connection until after the delegate is called
Browse files Browse the repository at this point in the history
  • Loading branch information
kcharwood committed Feb 29, 2012
1 parent 68e1376 commit 1bab351
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion AFNetworking/AFURLConnectionOperation.m
Expand Up @@ -351,11 +351,12 @@ - (void)cancel {
- (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;
}
}

Expand Down

0 comments on commit 1bab351

Please sign in to comment.