Hey,
I'm becomming desperate. I've got a NSTimer in my second ViewController.
Code:
-(IBAction)start {
myticker = [NSTimer scheduledTimerWithTimeInterval:0.01 target:self selector:@selector(showActivity) userInfo:nil repeats:YES];
}
Code:
-(IBAction)stop {
[myticker invalidate];
}
Code:
-(void)showActivity {
float currentTime = [time.text floatValue];
newTime = currentTime + 0.01;
time.text = [NSString stringWithFormat:@"%.2f", newTime];
}
newTime ist an instance variable (float) and time is the label where the time is shown.
Before calling the third ViewController, I stored the time like this:
Code:
-(IBAction)right {
[self stop];
ThirdViewController *screen = [[ThirdViewController alloc] initWithNibName:nil bundle:nil];
screen.modalTransitionStyle = UIModalTransitionStyleCrossDissolve;
screen.timelabel.text = [NSString stringWithFormat: @"%.2f", newTime];
[self presentModalViewController:screen animated:YES];
[screen release];
}
I stopped the timer and gave the time to the instance variable timelabel (UILabel).
In the third ViewController I created the same NSTimer with the same methods.
But when I open the third View Controller the timer starts from 0 again.
What's wrong about my code?