Having a problem with NSURLConnection, if I create a NSURLConnection and call [connection connectionWithRequest] let it load a little then call [connection cancel] most of t
I have not yet run into this problem, but this could also work without tying up your delegate object:
Since all delegate methods receive the calling Connection object as a parameter and you also know your actual active Connection object (or nil), simply ignore the delegation actions by comparing the two objects. This way a cancelled "ghost" Connection object can still call the delegate but not interfere with its internals.
- (void) connection:(NSURLConnection*) connection didReceiveData:(NSData*) data
{
if(connection != _URLConnection){return;}
...
[_incomingData appendData:data];
...
}
where _URLConnection is a property in your delegate set to an active Connection, or nil.