Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Added in cancel changes based on @zdzisiekpu's recommendation

Changed connection to be retained, and set the connection to be nil in
the cancel, success, and error case.
  • Loading branch information...
commit 68e13764afdf7adfba29e891095542002d8cfe2f 1 parent 8fbe65b
@kcharwood kcharwood authored
Showing with 6 additions and 1 deletion.
  1. +6 −1 AFNetworking/AFURLConnectionOperation.m
View
7 AFNetworking/AFURLConnectionOperation.m
@@ -85,7 +85,7 @@ static inline BOOL AFStateTransitionIsValid(AFOperationState fromState, AFOperat
@interface AFURLConnectionOperation ()
@property (readwrite, nonatomic, assign) AFOperationState state;
@property (readwrite, nonatomic, retain) NSRecursiveLock *lock;
-@property (readwrite, nonatomic, assign) NSURLConnection *connection;
+@property (readwrite, nonatomic, retain) NSURLConnection *connection;
@property (readwrite, nonatomic, retain) NSURLRequest *request;
@property (readwrite, nonatomic, retain) NSURLResponse *response;
@property (readwrite, nonatomic, retain) NSError *error;
@@ -351,6 +351,7 @@ - (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];
@@ -466,6 +467,8 @@ - (void)connectionDidFinishLoading:(NSURLConnection *)__unused connection {
}
[self finish];
+
+ self.connection = nil;
}
- (void)connection:(NSURLConnection *)__unused connection
@@ -480,6 +483,8 @@ - (void)connection:(NSURLConnection *)__unused connection
}
[self finish];
+
+ self.connection = nil;
}
- (NSCachedURLResponse *)connection:(NSURLConnection *)__unused connection
Please sign in to comment.
Something went wrong with that request. Please try again.