Initializer

init(fireAt:interval:target:selector:userInfo:repeats:)

Initializes a timer using the specified object and selector. あるタイマーをこの指定されたオブジェクトとセレクタを使って初期化します。

Declaration 宣言

init(fireAt date: Date, 
interval ti: TimeInterval, 
target t: Any, 
selector s: Selector, 
userInfo ui: Any?, 
repeats rep: Bool)

Parameters パラメータ

date

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

ti

For a repeating timer, this parameter contains the number of seconds between firings of the timer. If ti is less than or equal to 0.0, this method chooses the nonnegative value of 0.0001 seconds instead. 反復タイマーに対して、このプロパティはそのタイマーの発火それらの間の秒数を含みます。ti0.0より少ないまたは等しいならば、このメソッドは代わりに0.0001秒の非負の値を選びます。

target

The object to which to send the message specified by aSelector when the timer fires. The timer maintains a strong reference to this object until it (the timer) is invalidated. タイマーが発火する場合このオブジェクトに対してaSelectorによって指定されたメッセージを送ります。タイマーは、このオブジェクトに対する強い参照を、それ(タイマー)が無効にされるまで保守します。

aSelector

The message to send to target when the timer fires. タイマーが発火する場合targetに送ることになるメッセージ。

The selector should have the following signature: timerFireMethod: (including a colon to indicate that the method takes an argument). The timer passes itself as the argument, thus the method would adopt the following pattern: セレクタは以下のシグネチャを持つべきです:timerFireMethod:(メソッドがひとつの引数を取ることを指し示すコロンを含みます)。タイマーは、それ自身を引数として渡します、したがってメソッドは以下のパターンを採用するでしょう:


- (void)timerFireMethod:(NSTimer *)timer
userInfo

Custom user info for the timer. The timer maintains a strong reference to this object until it (the timer) is invalidated. This parameter may be nil. タイマーに対するあつらえのユーザ情報。タイマーは、このオブジェクトに対する強い参照を、それ(タイマー)が無効にされるまで保守します。このパラメータはnilであるかもしれません。

repeats

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

Return Value 戻り値

The receiver, initialized such that, when added to a run loop, it will fire at date and then, if repeats is true, every ti after that. そのレシーバ、それは初期化されて、実行ループに加えられる場合、それは発火をdateでそしてそれから、もしrepeatstrueならば、その後ti毎にするようになっています。

Discussion 議論

You must add the new timer to a run loop, using add(_:forMode:). Upon firing, the timer sends the message aSelector to target. (If the timer is configured to repeat, there is no need to subsequently re-add the timer to the run loop.) あなたは、この新しいタイマーを実行ループに、add(_:forMode:)を使って加えなければなりません。発火では、タイマーはメッセージaSelectortargetへと送ります。(タイマーが繰り返すように構成設定されるならば、続けてタイマーを実行ループへと再度追加する必要はありません。)

See Also 参照

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