Is it possible to catch NSURLConnection cancel
using a callback?
If I'm using this code
-(void) pleaseStopDownload {
cancelled = YES;
[conn cancel];
conn = nil;
[self myUpdateUImessage];
}
from time to myUpdateUImessage
is called before this callback
- (void)connection:(NSURLConnection *)connection didReceiveData:(NSData *)data {
NSLog(@"didReceiveData");
if (!cancelled) {
//this code inside brackets suddenly is calling:(
//not always but from time to time
summ += data.length;
if (_progressHandler != nil)
_progressHandler(data, summ, max);
} else {
return;
}
}
So the User interface is not updated properly! That is, the final UI is shown than progress UI.
EDIT the problem was about
NSOperationQueue *tempQueue = [[NSOperationQueue alloc] init];
[conn setDelegateQueue:tempQueue];
correct NSQueue
is NSOperationQueue *tempQueue = [NSOperationQueue mainQueue];