scheduledTimer(withTimeInterval:repeats:block:)
Creates a timer and schedules it on the current run loop in the default mode.
Declaration
class func scheduledTimer(withTimeInterval interval: TimeInterval, repeats: Bool, block: @escaping @Sendable (Timer) -> Void) -> TimerParameters
- interval:
The number of seconds between firings of the timer. If
intervalis less than or equal to0.0, this method chooses the nonnegative value of0.0001seconds instead. - repeats:
If
true, the timer will repeatedly reschedule itself until invalidated. Iffalse, the timer will be invalidated after it fires. - block:
A block to be executed when the timer fires.
The block takes a single
NSTimerparameter and has no return value.
Return Value
A new NSTimer object, configured according to the specified parameters.
Discussion
After interval seconds have elapsed, the timer fires, executing block.
See Also
Creating a Timer
scheduledTimer(timeInterval:target:selector:userInfo:repeats:)scheduledTimer(timeInterval:invocation:repeats:)init(timeInterval:repeats:block:)init(timeInterval:target:selector:userInfo:repeats:)init(timeInterval:invocation:repeats:)init(fire:interval:repeats:block:)init(fireAt:interval:target:selector:userInfo:repeats:)