-1

i use now both but i'm not sure which is better. what is exactly the difference? fuzzy question i know. preparing for wwdc

Peter Hosey
  • 95,783
  • 15
  • 211
  • 370
mahal tertin
  • 3,239
  • 24
  • 41
  • To be more precise: it is some kind of idle timer: 1.5 seconds after the user did something, i want to kick in a specific operation. Now i can choose either to add performSelector::afterDelay: and cancelPreviousPerformRequest or add the operation to a queue and cancel it every time the user does something and add it again. – mahal tertin Jun 07 '10 at 22:08

1 Answers1

1

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.

Peter Hosey
  • 95,783
  • 15
  • 211
  • 370