NSOperation - Forcing an operation to wait others dynamically

后端 未结 7 1840
情话喂你
情话喂你 2020-12-12 21:59

I am trying to implement an operation queue and I have the following scenario:

NSOperation A
NSOperation B
NSOperation C
NSOperation D
NSOperationQueue queue         


        
7条回答
  •  执念已碎
    2020-12-12 22:03

    As you've found, you can't really do this with dependencies because that only affects when an operation starts - and if you don't know you'll need the sub operations until the main one is running, so that's no good. You can't solve this problem with a single operation queue.

    However, since you're already running on an operation queue, there is no need to add the further operations to a queue. Just execute them synchronously in-place. You have to wait for them to return anyway, so why not?

提交回复
热议问题