Initializes a timer using the specified object and selector.
- iOS 2.0+
- macOS 10.2+
- Mac Catalyst 13.0+
- tvOS 9.0+
- watchOS 2.0+
The time at which the timer should first fire.
For a repeating timer, this parameter contains the number of seconds between firings of the timer. If
tiis less than or equal to
0, this method chooses the nonnegative value of
The object to which to send the message specified by
awhen the timer fires. The timer maintains a strong reference to this object until it (the timer) is invalidated.
The message to send to
targetwhen the timer fires.
The selector should have the following signature:
timer(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:
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
true, the timer will repeatedly reschedule itself until invalidated. If
false, the timer will be invalidated after it fires.
The receiver, initialized such that, when added to a run loop, it will fire at
date and then, if
ti after that.
You must add the new timer to a run loop, using
add(_:. Upon firing, the timer sends the message
target. (If the timer is configured to repeat, there is no need to subsequently re-add the timer to the run loop.)