One Logo Pool Ball
Foundation · IOS API REFERENCE

Timer

class · SDK 27.1

class Timer

Members (13)

static · iOS 10.0+

scheduledTimer

TypeScript
static scheduledTimer(interval: number, repeats: boolean, block: ((arg0: Timer) => void)): Timer
Swift declaration
class func scheduledTimer(withTimeInterval interval: TimeInterval, repeats: Bool, block: @escaping @Sendable (Timer) -> Void) -> Timer
init · iOS 10.0+

init

TypeScript
static initTimeIntervalRepeatsBlock(interval: number, repeats: boolean, block: ((arg0: Timer) => void)): Timer
Swift declaration
init(timeInterval interval: TimeInterval, repeats: Bool, block: @escaping @Sendable (Timer) -> Void)
method

fire

TypeScript
fire(): void
Swift declaration
func fire()
init · iOS 10.0+

init

TypeScript
static initFireIntervalRepeatsBlock(date: globalThis.Date, interval: number, repeats: boolean, block: ((arg0: Timer) => void)): Timer
Swift declaration
convenience init(fire date: Date, interval: TimeInterval, repeats: Bool, block: @escaping @Sendable (Timer) -> Void)
method

invalidate

TypeScript
invalidate(): void
Swift declaration
func invalidate()
get

fireDate

TypeScript
get fireDate(): globalThis.Date
Swift 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(): number
Swift declaration
var timeInterval: TimeInterval { get }
get · iOS 7.0+

tolerance

TypeScript
get tolerance(): number
Swift 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) | null
Swift declaration
var userInfo: Any? { get }
get

isValid

TypeScript
get isValid(): boolean
Swift 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_TimerPublisher
Swift declaration
static func publish(every interval: TimeInterval, tolerance: TimeInterval? = nil, on runLoop: RunLoop, in mode: RunLoop.Mode, options: RunLoop.SchedulerOptions? = nil) -> Timer.TimerPublisher

Returns 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 →