NSOperationQueue 依赖操作

前端之家收集整理的这篇文章主要介绍了NSOperationQueue 依赖操作前端之家小编觉得挺不错的,现在分享给大家,也给大家做个参考。
NSOperationQueue * operationQueue = [[NSOperationQueue alloc]init];

    NSInvocationOperation * invocationOp = [[NSInvocationOperation alloc]initWithTarget:self selector:@selector(invocationRun) object:nil];
    NSBlockOperation * blockOp = [NSBlockOperation blockOperationWithBlock:^{
        NSLog(@"blockOpRun_0");
    }];
    //invocationOp 依赖 blockOp => 也就是说 先执行 blockOp 然后再执行invocationOp
    [invocationOp addDependency:blockOp];

    [operationQueue addOperation:invocationOp];
    [operationQueue addOperation:blockOp];
原文链接:https://www.f2er.com/javaschema/284202.html

猜你在找的设计模式相关文章