【发布时间】:2012-03-01 10:48:43
【问题描述】:
我有一个 UITableViewController,我正在使用来自 Web 服务的数据进行填充。在下载数据时,我使用 NSInvocationOperation 和 NSOperationQueue 在后台线程上运行 Web 服务调用,同时在 UI 上显示进度指示器。这一切都很好,但我只想确保我正确处理了这些对象。我的代码如下:
NSOperationQueue *backgroundTaskQueue = [[NSOperationQueue alloc] init];
NSInvocationOperation *webServiceOp = [[NSInvocationOperation alloc]
initWithTarget:self
selector:@selector(loadListDataOperation)
object:nil];
[backgroundTaskQueue addOperation:webServiceOp];
[webServiceOp release];
我的内存管理知识告诉我应该在某个时候释放 backgroundTaskQueue,但不确定在哪里 - 它应该只是在 UITableViewController 的 dealloc() 方法中吗?
任何帮助表示赞赏,
乔纳森
【问题讨论】:
标签: objective-c uitableview release nsoperation nsoperationqueue