开发者

is there way to check if performSelector:withObject:afterDelay: has been registered?

开发者 https://www.devze.com 2023-04-12 08:20 出处:网络
I whould like to know if there is a way to determine ifperformSelector:withObject:afterDelay: for the given object has been called (registered to be called). (I could use cancelPreviousPerformRequests

I whould like to know if there is a way to determine if performSelector:withObject:afterDelay: for the given object has been called (registered to be called). (I could use cancelPreviousPerformRequestsWit开发者_如何学编程hTarget:selector:object: and re-call performSelector:withObject:afterDelay:, ok but I'm interested to know if there is the alternative).

Thanks


The best thing to do would be to make sure that the selector being called can be called multiple times safely.

For example, use a flag in the target object to track if the method has already been invoked e.g.

-targetSelector: (id) param
{
    if (!hasBeenRun) // hasBeenRun is a boolean intance variable
    {
        hasBeenRun = true;
        // other stuff
    }
}
0

精彩评论

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