Initializer

init(fire:interval:repeats:block:)

Initializes a timer for the specified date and time interval with the specified block. あるタイマーをこの指定された日付と時間間隔に対してこの指定されたブロックで初期化します。

Declaration 宣言

convenience init(fire date: Date, 
        interval: TimeInterval, 
         repeats: Bool, 
           block: @escaping (Timer) -> Void)

Parameters パラメータ

date

The time at which the timer should first fire. タイマーが最初に発火すべき時間。

interval

For a repeating timer, this parameter contains 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:). Upon firing, 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 タイマーを作成する