I've got a NSTimer and a label which shows the seconds counting down.
-(void)start {
myTimer = [NSTimer scheduledTimerWithTimeInterval:0.01 target:self selector:@selector(showActivity) userInfo:nil repeats:YES];
}
-(IBAction)stop {
[myTimer invalidate];
}
-(void)showActivity {
currentTime = [timeLabel.text floatValue];
currentTime -= 0.01;
timeLabel.text = [NSString stringWithFormat:@"%.2f", currentTime];
if (currentTime == 0) {
[self stop];
ResultViewController *screen = [[ResultViewController alloc] initWithNibName:nil bundle:nil];
screen.modalTransitionStyle = UIModalTransitionStyleCrossDissolve;
[self presentModalViewController:screen animated:YES];
[screen release];
}
}
- (void)viewDidLoad {
[super viewDidLoad];
timeLabel.text = @"60.0";
[self start];
}
So when the time is 0, the timer should stop and the ResultViewController should load, but when I do it the timer still counts down into negative numbers and nothing happens.
Is there anybody who can help me?
Thank you :)