Reputation: 26223
I have a section of code that sometimes needs to call "cancelPreviousPerformRequest" and other times does not. From my tests it seems that its fine to call this even if the selector has already been removed. I am just curious if this is acceptable, or is there someway to say "if (selector exists) remove it, otherwise do nothing"
[NSObject cancelPreviousPerformRequestsWithTarget:self selector:@selector(stopUpdatingCoreTemps:) object:@"SHUTDOWN"];
Upvotes: 0
Views: 213
Reputation: 10065
It's fine.
Basically, the runloop will just loop through all queued up performSelector...
. If your target isn't there, it won't do anything.
This only gets tricky if you have multiple runloops however. cancelPreviousPerformRequests...
only works on the current runloop.
Upvotes: 2