How to stop an NSInvocationOperation?

前端 未结 4 2073
情歌与酒
情歌与酒 2020-12-16 03:06

I have an NSInvocationOperation that would download and parse a series of NSXMLDocuments in the background to my UI responsive.

My attempt at stopping the Invocation

4条回答
  •  被撕碎了的回忆
    2020-12-16 03:27

    It's up to the implementation of your NSOperation object to actually stop what it's doing, clean up, and exit when it gets notified that it's been cancelled. Messaging that you want to cancel all operations on the queue will cause the queue to stop dequeueing new operations to run and will send the cancel message to any operations currently running.

    In your operation's main method, you should be checking for isCancelled and handling that state when you are actually cancelled.

    For more information, see the Creating and Managing Operation Objects in the Threading Programming Guide.

提交回复
热议问题