iOS-任务依赖-while
2022-09-27 本文已影响0人
笑破天
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<UITouch *> *)touches withEvent:(UIEvent *)event {
dic = [NSDictionary dictionary];
}
- (void)test {
dispatch_async(queue, ^{
BOOL finish = NO;
while (!finish) {
if (self->dic) {
NSLog(@"done");
finish = YES;
}
}
});
}