iOS reference / Foundation / TimerFoundation · IOS API REFERENCE
Timer class · SDK 27.1
class TimerMembers (13) static · iOS 10.0+ scheduledTimer TypeScript static scheduledTimer(interval: number, repeats: boolean, block: ((arg0: Timer) => void)): TimerSwift declaration class func scheduledTimer(withTimeInterval interval: TimeInterval, repeats: Bool, block: @escaping @Sendable (Timer) -> Void) -> Timerinit · iOS 10.0+ init TypeScript static initTimeIntervalRepeatsBlock(interval: number, repeats: boolean, block: ((arg0: Timer) => void)): TimerSwift declaration init(timeInterval interval: TimeInterval, repeats: Bool, block: @escaping @Sendable (Timer) -> Void)method fire TypeScript fire(): voidSwift declaration func fire()init · iOS 10.0+ init TypeScript static initFireIntervalRepeatsBlock(date: globalThis.Date, interval: number, repeats: boolean, block: ((arg0: Timer) => void)): TimerSwift declaration convenience init(fire date: Date, interval: TimeInterval, repeats: Bool, block: @escaping @Sendable (Timer) -> Void)method invalidate TypeScript invalidate(): voidSwift declaration func invalidate()get fireDate TypeScript get fireDate(): globalThis.DateSwift declaration var fireDate: Date { get set }set fireDate TypeScript set fireDate(value: globalThis.Date)Swift declaration var fireDate: Date { get set }get timeInterval TypeScript get timeInterval(): numberSwift declaration var timeInterval: TimeInterval { get }get · iOS 7.0+ tolerance TypeScript get tolerance(): numberSwift declaration var tolerance: TimeInterval { get set }set · iOS 7.0+ tolerance TypeScript set tolerance(value: number)Swift declaration var tolerance: TimeInterval { get set }get userInfo TypeScript get userInfo(): (unknown) | nullSwift declaration var userInfo: Any? { get }get isValid TypeScript get isValid(): booleanSwift declaration var isValid: Bool { get }static · iOS 13.0+ publish TypeScript static publish(interval: number, tolerance: (number) | null, runLoop: RunLoop, mode: RunLoop_Mode, options?: (RunLoop_SchedulerOptions) | null): Timer_TimerPublisherSwift declaration static func publish(every interval: TimeInterval, tolerance: TimeInterval? = nil, on runLoop: RunLoop, in mode: RunLoop.Mode, options: RunLoop.SchedulerOptions? = nil) -> Timer.TimerPublisherReturns a publisher that repeatedly emits the current date on the given interval.
- Parameters:
- interval: The time interval on which to publish events. For example, a value of `0.5` publishes an event approximately every half-second.
- tolerance: The allowed timing variance when emitting events. Defaults to `nil`, which allows any variance.
- runLoop: The run loop on which the timer runs.
- mode: The run loop mode in which to run the timer.
- options: Scheduler options passed to the timer. Defaults to `nil`.
- Returns: A publisher that repeatedly emits the current date on the given interval.
Skipped declarations 6 declarations were excluded from these bindings. Each reason comes from the generator or the iOS SDK compiler.
Timer.init(timeInterval:invocation:repeats:)
The iOS SDK compiler rejected this binding: 'NSInvocation' is unavailable in Swift: NSInvocation and related APIs not available
Timer.scheduledTimer(timeInterval:invocation:repeats:)
The iOS SDK compiler rejected this binding: 'NSInvocation' is unavailable in Swift: NSInvocation and related APIs not available
Timer.init(timeInterval:target:selector:userInfo:repeats:)
Objective-C selectors cannot cross the bridge.
Timer.scheduledTimer(timeInterval:target:selector:userInfo:repeats:)
Objective-C selectors cannot cross the bridge.
Timer.init(fireAt:interval:target:selector:userInfo:repeats:)
Objective-C selectors cannot cross the bridge.
Timer.init()
inherited init: cannot prove legal (class declares 7 custom initializers)
All Foundation types →