我有几个后台任务要处理,同时仍然保持UI响应。我开始创建和管理线程的路径,但很快就遇到了NSOperations。听起来像是更好的解决方案。 。 。iphone,如何创建NSOperationQueue
但是,我似乎无法获得对NSOperationQueue的参考。线程编程指南建议如下:
@implementation MyCustomClass
- (void)launchTaskWithData:(id)data
{
NSInvocationOperation* theOp = [[NSInvocationOperation alloc] initWithTarget:self
selector:@selector(myTaskMethod:) object:data];
// Add the operation to the internal operation queue managed by the application delegate.
[[MyAppDelegate sharedOperationQueue] addOperation:theOp];
}
// This is the method that does the actual work of the task.
- (void)myTaskMethod:(id)data
{
// Perform the task.
}
。 。 。但我(更重要的是,编译器)在我的应用程序中实现代码时看不到'sharedOperationQueue'消息。
我在想什么?是否sharedOperationQueue已弃用且不再可用?我怎样才能得到一个NSOperationQueue引用?
链接,请123 – atreat