iOS-任务依赖-while

NSOperation、dispatch_semaphore_t、子线程while

子线程while:

- (void)viewDidLoad {
    [super viewDidLoad];
    queue = dispatch_queue_create("com.xx.test", DISPATCH_QUEUE_SERIAL);
    [self test];
}

- (void)touchesBegan:(NSSet *)touches withEvent:(UIEvent *)event {
    dic = [NSDictionary dictionary];
}

- (void)test {
    dispatch_async(queue, ^{
        BOOL finish = NO;
        while (!finish) {
            if (self->dic) {
                NSLog(@"done");
                finish = YES;
            }
        }
    });
}

你可能感兴趣的:(iOS-任务依赖-while)