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 j开发者_如何学Goust 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"];
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.
精彩评论