is there way to check if performSelector:withObject:afterDelay: has been registered?
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
}
}
精彩评论