创建NSOperation并将其放入NSOperationQueue时,我从不会看到main()被调用。只有start()被调用。我没有做任何事情,真的。作为一个简单的测试,我写了这个:未在非并发中调用main()NSOperation
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。 – ayl