NSURLConnection cancel
コールバックを使用してキャッチすることは可能ですか?
このコードを使用している場合
-(void) pleaseStopDownload {
cancelled = YES;
[conn cancel];
conn = nil;
[self myUpdateUImessage];
}
from time tomyUpdateUImessage
は、このコールバックの前に呼び出されます
- (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;
}
}
そのため、ユーザー インターフェイスが適切に更新されません。つまり、進行中の UI よりも最終的な UI が表示されます。
問題があった編集
NSOperationQueue *tempQueue = [[NSOperationQueue alloc] init];
[conn setDelegateQueue:tempQueue];
正しいNSQueue
です NSOperationQueue *tempQueue = [NSOperationQueue mainQueue];