Je travaille sur un compte à rebours et j'ai du mal à obtenir l'instruction if pour arrêter le temporisateur lorsque le compte est inférieur à 0. Toute indication sur la résolution serait grandement apprécié. Merci d'avance pour votre aide ..NSTimer - si l'instruction ne fonctionne pas dans le temporisateur - CountDown Timer
-(void) startCountdown{
time = 90;
//NSLog[@"Time Left %d Seconds", time];
//This timer will call the function updateInterface every 1 second
myTimer = [NSTimer scheduledTimerWithTimeInterval:1 target:self selector:@selector(updateInterface:) userInfo:nil repeats:YES];
}
-(void) updateInterface:(NSTimer*)theTimer{
if(time >= 0){
time --;
CountDownText.text = [NSString stringWithFormat:@"%d", time];
NSLog(@"Time Left %d Seconds", time);
}
else{
CountDownText.text [email protected]"Times Up!";
NSLog(@"Times Up!");
// Timer gets killed and no longer calls updateInterface
[myTimer invalidate];
}
}
Quel est le problème? Est-ce que la minuterie continue à compter? –