NSOperation

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)