すべて異なる時間(25、50、1分、1分30秒...)で開始する複数のタイマーを作成したいのですが、0に達したときに停止し、ゼロに達したときに停止する方法がわかりません。別のビューへの「プレーヤー」。
これが私の.hファイルです
@interface ViewController :UIViewController {
IBOutlet UILabel *seconds;
NSTimer *timer;
int MainInt;
}
@end
そしてここに私の.mファイルがあります
@implementation ViewController
-(void)countDownDuration {
MainInt -= 1;
seconds.text = [NSString stringWithFormat:@"%i", MainInt];
}
-(IBAction)start:(id)sender {
MainInt = 25;
timer = [NSTimer scheduledTimerWithTimeInterval:1.0
target:self
selector:@selector(countDownDuration)
userInfo:nil
repeats:YES];
}
@end