1

我正在使用 NSOperationQueue 和 NSOperation 进行异步下载操作。该过程在应用加载时在应用委托中启动。这是代码

for(Campaign *cmp in campaigns)
{
  DownloadOperation *operation = [[DownloadOperation alloc] initWithCamapign:cmp];
  [self.downloadQueue addOperation:operation];
}

运行一段时间后,应用程序崩溃发送消息

[下载操作保留]:发送到已释放实例的消息

下载操作扩展了 NSOperation

下载操作:NSOperation

下载队列在appdelagate中声明如下

NSOperationQueue *downloadQueue;
@property(nonatomic,strong) NSOperationQueue *downloadQueue;

我正在使用 ARC。我如何告诉编译器该对象不应该被释放?

补充:我已经调试了一段时间的应用程序。我想分享我的发现。类 DownloadOperation 正在实现一个 delagate。委托基本上接收 HTTP 操作的结果。当处理 HTTP 请求的类尝试将响应发布回 DownloadOperation 类时,将生成异常。那个时候叫

[self.delegate didLoadPage:pageNumber withResults:results]

我猜是DownloadOperation类的委托被释放了?

4

0 回答 0