Quote:
Originally Posted by doopster
Hi. Ive been making a game and for some reason instead of this number counting down by 1 its been counting down by 4. Here is my code below:
Code:
- (IBAction)count:(id)sender {
myTimer = 60;
myTicker = [NSTimer scheduledTimerWithTimeInterval: 0.5 target: self selector: @selector(showActivity) userInfo: nil repeats: YES];
}
- (void)showActivity {
myTimer = myTimer-1;
text.text=[NSString stringWithFormat:@"%i", myTimer];
}
Please Help 
|
Why are you calling showActivity every 0.5 seconds? If it is a timer, wouldn't you want it calling every second? I would set it up personally as:
Code:
-(void)someMethod {
myTimer = 60;
myTicker = [NSTimer scheduledTimerWithTimeInterval:1 target:self selector:@selector(showActivity) userInfo:nil repeats:YES];
}
-(void)showActivity {
myTimer = myTimer - 1;
textView.text = [NSString stringWithFormat:@"%d",myTimer];
}
Declare myTicker as an NSTimer and myTimer as an integer.
Code:
int myTimer;
NSTimer *myTicker;