开发者

cancelPreviousPerformRequest vs cancelAllOperations

开发者 https://www.devze.com 2023-01-02 12:00 出处:网络
i use now both but i\'m not sur开发者_如何学JAVAe which is better. what is exactly the difference? fuzzy question i know. preparing for wwdcSending a cancelAllOperations message to an operation queue

i use now both but i'm not sur开发者_如何学JAVAe which is better. what is exactly the difference? fuzzy question i know. preparing for wwdc


Sending a cancelAllOperations message to an operation queue cancels all the operations in that queue (that is, it tells the operations to cancel), whereas cancelPreviousPerformRequestsWithTarget: tells the target object to cancel all delayed performs it had previously been told to do.

There is no “better” here; the two methods are incomparable. One cancels NSOperations; the other cancels delayed-perform requests. Which cancellation you use depends entirely on whether you made an NSOperation and put it an NSOperationQueue or sent a delayed-perform request.

0

精彩评论

暂无评论...
验证码 换一张
取 消