백그라운드 스레드에서 다운로드를 수행하려고합니다.이 때문에 NSOperationQueue 인스턴스를 만들고 NSInvocationOperation 인스턴스를 추가했습니다. setDelegateQueue가 iOS5에서는 작동하지 않지만 iOS6에서는 정상적으로 작동합니다.
operationQueue = [NSOperationQueue new];
// set maximum operations possible
[operationQueue setMaxConcurrentOperationCount:1];
NSInvocationOperation *operation = [[NSInvocationOperation alloc] initWithTarget:self
selector:@selector(startBackgroundThread:)
object:data];
[operationQueue addOperation:operation];
[operation release];
지금 startBackgroundThread에서, 나는 새로운있는 NSURLConnection을 만들고 그것에 operationQueue을 파견했다. iOS6의
에서
currentConnection = [[NSURLConnection alloc] initWithRequest:request delegate:self startImmediately:NO];
if (self.operationQueue) {
[currentConnection setDelegateQueue:self.operationQueue];
}
[currentConnection start];
행동은 iOS6의에 정확히 잘 작동. 스레드가 생성되고 NSURLConnection 콜백이 동일한 백그라운드 스레드에서 위임됩니다. iOS5를하고 iOS5.1
스레드가 생성됩니다 만있는 NSURLConnection 대표가 호출되지 않은에서
행동.
iOS5에서 고려해야 할 사항이 누락 되었습니까? Apple에서 제공 한 설명서를 읽었으나 관련 내용은 언급되지 않았습니다.
무엇을 다운로드해야합니까? 웹 페이지 콘텐츠의 이미지입니까? – pradeepa
runloop이 실행중인 스레드에서 연결을 시작하면 대리인이 호출되지 않습니다. – pradeepa
실행 루프가 항상 실행되는 메인 스레드에서 연결을 시작하십시오. – pradeepa