- 创建队列
NSOperationQueue * queue = [[NSOperationQueue alloc]init];
- 创建三个操作
NSOperation * A = [NSBlockOperation blockOperationWithBlock:^{
NSLog{@"A"};
}];
NSOperation * B = [NSBlockOperation blockOperationWithBlock:^{
NSLog{@"B"};
}];
NSOperation * C = [NSBlockOperation blockOperationWithBlock:^{
NSLog{@"C"};
}];
- 添加依赖
[C addDependency:a];
[C addDependency:b];
- 执行操作
[queue addOperation:a];
[queue addOperation:b];
[queue addOperation:c];