I have a NSURLConnection that is working fine when I allow the load to complete. But if the user hits the back button, meaning the webview will dissappear, I want to cancel the NSURLConnection in progress. But if have the webview call into this class when viewWillDissapear is called, and then I do:
[conn cancel]
I get an NSINValidArgument exception.
The connection is defined as instance data in the .h file as:
NSURLConnection *conn;
The async is initiated here:
NSURLRequest *request = [NSURLRequest requestWithURL:[NSURL URLWithString:articleURL]];
if ([NSURLConnection canHandleRequest:request] && reachable) {
// Set up an asynchronous load request
conn = [NSURLConnection connectionWithRequest:request delegate:self];
loadCancelled = NO;
if (conn) {
NSLog(@" ARTICLE is REACHABLE!!!!");
self.articleData = [NSMutableData data];
}
}