Contents

CMTimebaseSetTimerNextFireTime(_:timer:fireTime:flags:)

Sets the time on the timebase’s timeline at which the timer should fire next.

Declaration

func CMTimebaseSetTimerNextFireTime(_ timebase: CMTimebase, timer: CFRunLoopTimer, fireTime: CMTime, flags: UInt32) -> OSStatus

Discussion

The timer must be on the list of timers the timebase manages. The timebase continues to update the timer’s “NextFireDate” according to time jumps and effective rate changes. If fireTime is not numeric, or if the timebase is not moving, the “NextFireDate” is set to a future date.

Due to the way that CFRunLoopTimers are implemented, if a timer passes through a state in which it is due to fire, it may fire even if its rescheduled before the runloop runs again. Clients should take care to avoid temporarily scheduling timers in the past. For example, set the timebase’s rate or time before you set the timer’s next fire time, if you are doing both at once. If setting the timebase’s rate or time might put the timer’s fire time in the past, you may need to set the fire time to kCMTimeInvalid across the timebase change.

See Also

Interacting with Timers