Determining a "first fire" with an NSTimer
I'm using a repeating NSTimer for my game that is initialized when my view loads. There's an "if" statement in my selector method that waits for the a boolean value to equal YES, effectively starting the timer until the boolean value returns to false.
So here's my issue:
If the NSTimer is defined as repeating every 10 seconds, the first time my code is fired (immediately after the boolean value is set to YES) could actually be any random time value between 1 & 10.. because the timer is randomly firing even thought the boolean is false.
Is there a more reliable way to use the timer so that I get a full 10 second interval immediately after my boolean is set to YES?
I can think of a work around that suits my needs... basically, set the NSTimer to fire every 1 second and include a tick integer so that the selector method runs every time the tick gets to 10...
... but I'm still curious... is there a more efficient solution or a more efficient way to use NSTimer in general?
Thanks!
|