Initializer

init(timeInterval:repeats:block:)

Initializes a timer object with the specified time interval and block. あるタイマーオブジェクトをこの指定された時間間隔とブロックで初期化します。

Declaration 宣言

init(timeInterval interval: TimeInterval, 
repeats: Bool, 
block: @escaping (Timer) -> Void)

Parameters パラメータ

interval

The number of seconds between firings of the timer. If interval is less than or equal to 0.0, this method chooses the nonnegative value of 0.0001 seconds instead. タイマーの発火それらの間の秒数。interval0.0より少ないまたは等しいならば、このメソッドは代わりに0.0001秒の非負の値を選びます。

repeats

If true, the timer will repeatedly reschedule itself until invalidated. If false, the timer will be invalidated after it fires. trueならば、タイマーは、無効にされるまで繰り返しそれ自身を予定します。falseならば、タイマーはそれが発火した後に無効にされます。

block

A block to be executed when the timer fires. The block takes a single Timer parameter and has no return value. タイマーが発火する時に実行されることになるブロック。ブロックは、単一のTimerパラメータを取り、戻り値を持ちません。

Return Value 戻り値

A new Timer object, configured according to the specified parameters. ある新しいTimerオブジェクト、それは指定されたパラメータによって構成設定されます。

Discussion 議論

You must add the new timer to a run loop, using add(_:forMode:). Then, after interval seconds have elapsed, the timer fires, executing block. (If the timer is configured to repeat, you don’t need to add the timer to the run loop again.) あなたは、この新しいタイマーを実行ループに、add(_:forMode:)を使って加えなければなりません。それから、interval秒が経過した後に、タイマーは発火して、blockを遂行します。(タイマーが繰り返すように構成設定されるならば、あなたはタイマーを実行ループに再び加える必要はありません。)

See Also 参照

Creating a Timer タイマーを作成する