new to the iOS SDK and Objective-C and just have a quick question regarding the NSTimeInterval.
I have a really simple game, and I want to show for how long the game have been played (so that I can save away a best time).
Now, of course if I set the label’s text with something like this:
NSTimeInterval elapsedTime = [startDate timeIntervalSinceNow];
theLabel.text = [NSString stringWithFormat:@"%.2f", -elapsedTime];
The text of the label will be how long time it will have passed since the game started, which is 0 seconds.
In what way can I have the elapsedTime object “running in the background” so that the player can se for how long he/she have played at all times?
Have a look as the NSTimer class to schedule a timer for a preset time and update the label in the callback.