Reputation: 7764
How can I cancel performSelectorOnMainThread
?
I have this code:
myClass = [[MyClass alloc] init];
[myClass performSelectorOnMainThread:@selector(setupPlayer) withObject:nil waitUntilDone:YES];
Upvotes: 2
Views: 1363
Reputation: 40437
If you're careful about the thread on which you originally queued the message, you can cancel it by calling + (void)cancelPreviousPerformRequestsWithTarget:(id)aTarget
on that same thread. That previous answer was missing an important bit:
You cannot cancel messages queued using this method. If you want the option of canceling a message on the current thread, you must use either the performSelector:withObject:afterDelay: or performSelector:withObject:afterDelay:inModes: method.
Upvotes: 2
Reputation: 55344
Per the documentation:
You cannot cancel messages queued using this method.
Upvotes: 3