Timer
public extension Timer
-
schedule: Creates and schedules a one-time
NSTimerinstance.Note
Timer doesn’t need to be invalidated after using this function.
Seealso
CFRunLoopTimerCreateWithHandler()
Declaration
Swift
static func schedule(withDelay delay: TimeInterval, handler: @escaping (CFRunLoopTimer?) -> Void) -> TimerParameters
delayThe delay before execution.
handlerA closure to execute after
delay.Return Value
The newly-created
NSTimerinstance. -
schedule: Creates and schedules a repeating
NSTimerinstance.Warning
Timer should be invalidated after using this function. Use
timer.invalidate()Declaration
Swift
static func schedule(repeatInterval interval: TimeInterval, handler: @escaping (CFRunLoopTimer?) -> Void) -> TimerParameters
repeatIntervalThe interval between each execution of
handler. Note that individual calls may be delayed; subsequent calls tohandlerwill be based on the time theNSTimerwas created.handlerA closure to execute after each
repeatInterval.Return Value
The newly-created
NSTimerinstance.
Timer Extension Reference