我创建了一个 NSOperation 子类来处理一些 zip 归档操作。无论如何,如果我覆盖-start或-main此代码块总是发生:
if ([NSThread isMainThread]) {
    NSLog(@"I am in the main thread");
    return;
}
知道发生了什么吗?
我试过添加这个块:
- (void) start {  //also tried overriding main
    if ([NSThread isMainThread]) {
        NSLog(@"In main thread, trying again");
        dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0), ^{
            [self start];
        });
        return;
        //hard working code etc...
        //cpu intensive zip operations...
    }
但这会导致崩溃,这是EXC_BAD_ACCESS指向dispatch_async线路的违规行为。