This is not all the code. I have made sure that I have declared everything correctly however the label is not changing as 'seconds' is decreasing.
I'm not sure why as in 'subtractTime' I have made timerLabel.text equal to the string with format using seconds which "should" and is counting down as I use an alert to reset the game and so even though the label isn't changing, I know it is counting down otherwise the alert wouldn't be triggered from 'seconds' equalling 0.
- (void)setupGame;
{
seconds = 30;
count = 0;
timerLabel.text = [NSString stringWithFormat: @"Time: %i", seconds];
scoreLabel.text = [NSString stringWithFormat: @"Score: %i", count];
timer = [NSTimer scheduledTimerWithTimeInterval:1.0
target:self
selector:@selector(subtractTime)
userInfo:nil
repeats:YES];
}
- (void)subtractTime;
{
seconds--;
timerLabel.text = [NSString stringWithFormat:@"Time: %i", seconds];
if (seconds == 0)
{
[timer invalidate];
UIAlertView *alert = [[UIAlertView alloc] initWithTitle: @"Time is up !"
message: [NSString stringWithFormat: @"You Scored %i points", count]
delegate:self
cancelButtonTitle: @"Play Again"
otherButtonTitles:nil];
[alert show];
}
}
@end