I have to stop the call in the fenumeration.
NSTimeInterval delay = 2; for (NSString* sentence in sentences) { [sentenceHandler performSelector:@selector(parseSentence:) withObject:sentence afterDelay:delay]; delay += 2; }
How to stop this call from above? I tried:
[NSObject cancelPreviousPerformRequestsWithTarget:sentenceHandler
selector:@selector(parseSentence) object:nil];
but there's no effect? Does it only quit one of the many calls in the loop?
You have two options. You could use this which would remove all queued calls to parseSentence:
:
[NSObject cancelPreviousPerformRequestsWithTarget:sentenceHandler];
Or you can remove each one individually (Note the colon ":" after the method parseSentence
):
[NSObject cancelPreviousPerformRequestsWithTarget:sentenceHandler
selector:@selector(parseSentence:)
object:sentence];
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With