美文网首页
NSOperation

NSOperation

作者: 事件_666 | 来源:发表于2017-04-25 20:03 被阅读0次

    NSOperation 两个子类 NSBlockOperation NSInvocationOperation

      NSBlockOperation *b1 = [NSBlockOperation blockOperationWithBlock:^{
        sleep(2);
        NSLog(@"这也行");
    }];
    [b1 addExecutionBlock:^{
        NSLog(@"都  行");
    }];
    [b1 setCompletionBlock:^{
        NSLog(@"执行完毕");
    }];
    
    NSBlockOperation *b2  = [NSBlockOperation blockOperationWithBlock:^{
        NSLog(@"-=-=-=-=-=======-----====");
    }];
    [b1 addDependency:b2];//添加依赖
    [b2 start];
    [b1 start];
    

    相关文章

      网友评论

          本文标题:NSOperation

          本文链接:https://www.haomeiwen.com/subject/jeqbzttx.html