gpt4 book ai didi

iphone - setDelegate Queue 在 iOS5 上不起作用,但在 iOS 6 上运行良好

转载 作者:行者123 更新时间:2023-11-29 13:21:05 25 4
gpt4 key购买 nike

我正在尝试在后台线程中执行下载。为此,我创建了一个 NSOperationQueue 实例并向其添加了一个 NSInvocationOperation 实例。

        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 分派(dispatch)给它。

    currentConnection = [[NSURLConnection alloc] initWithRequest:request delegate:self startImmediately:NO];
if (self.operationQueue) {
[currentConnection setDelegateQueue:self.operationQueue];
}
[currentConnection start];

iOS6 中的行为

在 iOS6 上工作得很好。一个线程被创建并且 NSURLConnection 回调它在同一个后台线程上委托(delegate)。

iOS5 和 iOS5.1 中的行为

创建了一个线程,但未调用 NSURLConnection 委托(delegate)。

我是否遗漏了一些需要在 iOS5 中考虑的内容?我已经阅读了 Apple 提供的文档,但没有提到与此相关的内容。

最佳答案

这是 iOS 5 上的一个已知问题。请参阅 http://openradar.appspot.com/10529053

关于iphone - setDelegate Queue 在 iOS5 上不起作用,但在 iOS 6 上运行良好,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/14336708/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com