Ive got a timer that im using to simulate a coin flip (practice makes perfect right?) well It will only gofrom 10 to 9 immediately and not continue. I cannot figure out what is wrong, is anything wrong?
HTML Code:
-(IBAction)flipCoin {
time = 10.0;
timer = [NSTimer scheduledTimerWithTimeInterval:0.5 target:self selector:@selector(updateCoin) userInfo:nil repeats:false];
}
-(void)updateCoin{
time = time - 1;
if(time == 0){
[timer invalidate];
[self showCoin];
} else {
[self updateCoinAnim];
}
}
-(void)updateCoinAnim{
coinWindow.image = [UIImage imageNamed:[NSString stringWithFormat:@"coin_anim_step_%i.png", time]];
// for testing
mainText.text = [NSString stringWithFormat:@"%i", time];
}
-(void)showCoin{
coin = 1 + arc4random() %2;
coinWindow.image = [UIImage imageNamed:[NSString stringWithFormat:@"coin_%i.png", coin]];
}