开发者

cancelPreviousPerformRequest if none exist?

开发者 https://www.devze.com 2023-02-22 11:31 出处:网络
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

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.

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号