I’ve tried to use both:
[NSTimer scheduledTimerWithTimeInterval:2.0
target:self
selector:@selector(enableGestures)
userInfo:nil
repeats:NO];
and
[self performSelector:@selector(enableGestures) withObject:nil afterDelay:2.0];
to trigger the enableGestures method, however in both versions it is triggered twice! (First when the timer starts and second after 2 seconds). Same thing with the second snippet. Why ?
thanks
The selector for the
scheduledTimerWithTimeInterval:target:selector:userInfo:repeats:message should have this signature:I wrote a little test code, and without a proper signature for the selector, the selector is sometimes called immediately, and then again when the timer finishes. When I changed it to a proper signature, the selector was first called after the appropriate delay. I never saw this problem with a properly formatted signature, and about half the time saw this problem with the improper signature.
I tried the second version, and it worked correctly every time.
If this is happening consistently with both versions of timing code, something else somewhere in the code is sending the
enableGesturesmessage.