【发布时间】:2013-02-02 04:30:48
【问题描述】:
在创建 NSOperation 并将其放入 NSOperationQueue 时,我从来没有看到 main() 被调用过。只有 start() 被调用。我没有做任何花哨的事情,真的。作为一个简单的测试,我写了这个:
NSOperationQueue *testOperationQueue = [[NSOperationQueue alloc] init];
MyTestOperation *testOperation = [[MyTestOperation alloc] init];
[testOperationQueue addOperation:testOperation];
在 MyTestOperation.m 中:
- (void)main
{
NSLog(@"testing if main is getting called");
}
- (void)start
{
NSLog(@"testing if start is getting called");
}
MyTestOperation.h 看起来像这样:
#import <Foundation/Foundation.h>
@interface MyTestOperation : NSOperation
@end
我是否遗漏了一些明显的东西?
[编辑说明:我实际上是指非并发,不是并发(如上一个标题中所写)。]
【问题讨论】:
-
“
MyTestOperation”的“@interface”.h 文件是什么样的? -
我已经包含了上面的 MyTestOperation.h。
标签: objective-c nsoperation nsoperationqueue