Function

CFRunLoopTimerCreateWithHandler

Creates a new CFRunLoopTimer object with a block-based handler.

Declaration

CFRunLoopTimerRef CFRunLoopTimerCreateWithHandler(CFAllocatorRef allocator, CFAbsoluteTime fireDate, CFTimeInterval interval, CFOptionFlags flags, CFIndex order, void (^block)(CFRunLoopTimerRef timer));

Parameters

allocator

The allocator to use to allocate memory for the new object. Pass NULL or kCFAllocatorDefault to use the current default allocator.

fireDate

The time at which the timer should first fire. The fine precision (sub-millisecond at most) of the fire date may be adjusted slightly by the timer if there are implementation reasons to do so.

interval

The firing interval of the timer. If 0 or negative, the timer fires once and then is automatically invalidated. The fine precision (sub-millisecond at most) of the interval may be adjusted slightly by the timer if implementation reasons to do so exist.

flags

Currently ignored. Pass 0 for future compatibility.

order

A priority index indicating the order in which run loop timers are processed. Run loop timers currently ignore this parameter. Pass 0.

block

The block invoked when the timer fires. The block takes one argument:

timer

The run loop timer that is firing.

Return Value

The new CFRunLoopTimer object. Ownership follows the Create Rule described in Ownership Policy.

Discussion

A timer needs to be added to a run loop mode before it will fire. To add the timer to a run loop, use CFRunLoopAddTimer. A timer can be registered to only one run loop at a time, although it can be in multiple modes within that run loop.

See Also

CFRunLoopTimer Miscellaneous Functions

CFRunLoopTimerCreate

Creates a new CFRunLoopTimer object with a function callback.

CFRunLoopTimerDoesRepeat

Returns a Boolean value that indicates whether a CFRunLoopTimer object repeats.

CFRunLoopTimerGetContext

Returns the context information for a CFRunLoopTimer object.

CFRunLoopTimerGetInterval

Returns the firing interval of a repeating CFRunLoopTimer object.

CFRunLoopTimerGetNextFireDate

Returns the next firing time for a CFRunLoopTimer object.

CFRunLoopTimerGetOrder

Returns the ordering parameter for a CFRunLoopTimer object.

CFRunLoopTimerGetTypeID

Returns the type identifier of the CFRunLoopTimer opaque type.

CFRunLoopTimerInvalidate

Invalidates a CFRunLoopTimer object, stopping it from ever firing again.

CFRunLoopTimerIsValid

Returns a Boolean value that indicates whether a CFRunLoopTimer object is valid and able to fire.

CFRunLoopTimerSetNextFireDate

Sets the next firing date for a CFRunLoopTimer object .