Pause NSOperation

依然范特西╮ 提交于 2019-12-03 00:31:51

The question is a bit vague, so it's hard to say without knowing all of the code in play. With that said, I may approach the problem by:

Option 1. In your subclass of NSOperation, add your own atomic KVO property "isPaused". Within the operation itself, observe that property and handle accordingly if it ever changes.

Option 2. Are you ever suspending the Operation Queue itself? If so, consider observing that property from within your operations, and each one independently can take action if that value changes.

Option 3. Cancel all operations in the queue, and if the view appears again, just restart with new operations.

Overall, though, there is no magic bullet for pausing operations already in progress. You'll have to bake your own solution. The damage shouldn't be too bad though.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!