---
title: "CMTimebaseAddTimer(_:timer:runloop:)"
framework: coremedia
role: symbol
role_heading: Function
path: "coremedia/cmtimebaseaddtimer(_:timer:runloop:)"
---

# CMTimebaseAddTimer(_:timer:runloop:)

Adds the timer to the list of timers the timebase manages.

## Declaration

```swift
func CMTimebaseAddTimer(_ timebase: CMTimebase, timer: CFRunLoopTimer, runloop: CFRunLoop) -> OSStatus
```

## Discussion

Discussion The timer must be a repeating runloop timer (with a very long interval at least as long as the constant kCMTimebaseVeryLongCFTimeInterval) attached to a runloop. The timebase retains the timer, and maintains its “NextFireDate” according to the CMTime set using CMTimebaseSetTimerNextFireTime(_:timer:fireTime:flags:). Until the first call to CMTimebaseSetTimerNextFireTime, the system sets the “NextFireDate” to a future time. The function retains the  runloop you specify, which must be the runloop you attached to the timer when you created it. The system uses the retained runloop to call CFRunLoopWakeUp() when the timebase modifies the timer’s fire date.

## See Also

### Interacting with Timers

- [CMTimebaseAddTimerDispatchSource(_:timerSource:)](coremedia/cmtimebaseaddtimerdispatchsource(_:timersource:).md)
- [CMTimebaseRemoveTimer(_:timer:)](coremedia/cmtimebaseremovetimer(_:timer:).md)
- [CMTimebaseRemoveTimerDispatchSource(_:timerSource:)](coremedia/cmtimebaseremovetimerdispatchsource(_:timersource:).md)
- [CMTimebaseSetTimerNextFireTime(_:timer:fireTime:flags:)](coremedia/cmtimebasesettimernextfiretime(_:timer:firetime:flags:).md)
- [CMTimebaseSetTimerToFireImmediately(_:timer:)](coremedia/cmtimebasesettimertofireimmediately(_:timer:).md)
- [CMTimebaseSetTimerDispatchSourceNextFireTime(_:timerSource:fireTime:flags:)](coremedia/cmtimebasesettimerdispatchsourcenextfiretime(_:timersource:firetime:flags:).md)
- [CMTimebaseSetTimerDispatchSourceToFireImmediately(_:timerSource:)](coremedia/cmtimebasesettimerdispatchsourcetofireimmediately(_:timersource:).md)
