コールバックを使用してNSURLConnection cancel
をキャッチすることは可能ですか?NSURLConnectionキャンセルコールバック
私はこのコードこのコールバックだから、ユーザーインターフェイスが正しく更新されない
- (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;
}
}
前に呼び出されmyUpdateUImessage
までの時間から
-(void) pleaseStopDownload {
cancelled = YES;
[conn cancel];
conn = nil;
[self myUpdateUImessage];
}
を使用している場合は!つまり、最終UIは進捗UIよりも表示されます。
EDIT 問題を約
NSOperationQueue *tempQueue = [[NSOperationQueue alloc] init];
[conn setDelegateQueue:tempQueue];
正しいNSQueue
はNSOperationQueue *tempQueue = [NSOperationQueue mainQueue];