I am implementing a countdown method in my game, which will use a 15 second countdown. I have been looking around for different ways of implementing this and believe NSTimer is the way to go.
However, someone told me that it can be impacted by processor speed etc. and my question is if this is true and if so, how do I counter for it?
I have seen this: NSTimer but dont fully understand the impact of this.
Is there any other way of guarantee 15 second downtime and all devices?
I don’t understand your last sentence…
However, I believe your friends are right that it is slightly off compared to what actual seconds countdown to but I assure you that the difference is so small that it’s not noticeable, especially for a game.
The reason for the difference is because you set an NSTimer to execute in one second, when it executes it updates the countdown on the screen then repeats. My guess is that NSTimer doesn’t start to repeat until after it finishes executing your method so each NSTimer second is nano-fractions of a second longer than a real second.
Apple may be one step ahead of me and invokes the repeat before the execute, however, I’m not sure.
Either way, like I said, unless you’re doing something major other than just updating the screen each second, your users shouldn’t notice a difference at all.