Class

CADisplayLink

A timer object that allows your application to synchronize its drawing to the refresh rate of the display.

Declaration

@interface CADisplayLink : NSObject

Overview

Your application initializes a new display link, providing a target object and a selector to be called when the screen is updated. To synchronize your display loop with the display, your application adds it to a run loop using the addToRunLoop:forMode: method

Once the display link is associated with a run loop, the selector on the target is called when the screen’s contents need to be updated. The target can read the display link’s timestamp property to retrieve the time that the previous frame was displayed. For example, an application that displays movies might use the timestamp to calculate which video frame will be displayed next. An application that performs its own animations might use the timestamp to determine where and how displayed objects appear in the upcoming frame.

The duration property provides the amount of time between frames at the maximumFramesPerSecond. To calculate the actual frame duration, use targetTimestamp - timestamp. You can use actual frame duration in your application to calculate the frame rate of the display, the approximate time that the next frame will be displayed, and to adjust the drawing behavior so that the next frame is prepared in time to be displayed.

Your application can disable notifications by setting the paused property to YES. Also, if your application cannot provide frames in the time provided, you may want to choose a slower frame rate. An application with a slower but consistent frame rate appears smoother to the user than an application that skips frames. You can define the number of frames per second by setting the preferredFramesPerSecond property.

When your application finishes with a display link, it should call invalidate to remove it from all run loops and to disassociate it from the target.

CADisplayLink should not be subclassed.

Topics

Creating Instances

+ displayLinkWithTarget:selector:

Returns a new display link.

Scheduling the Display Link to Send Notifications

- addToRunLoop:forMode:

Registers the display link with a run loop.

- removeFromRunLoop:forMode:

Removes the display link from the run loop for the given mode.

- invalidate

Removes the display link from all run loop modes.

Configuring the Display Link

duration

The time interval between screen refresh updates.

preferredFramesPerSecond

The preferred frame rate for the display link callback.

frameInterval

The number of frames that must pass before the display link notifies the target again.

Deprecated
paused

A Boolean value that states whether the display link’s notifications to the target are suspended.

timestamp

The time value associated with the last frame that was displayed.

targetTimestamp

The time value associated with the next frame that was displayed.

Relationships

Inherits From

See Also

Animation Timing

CACurrentMediaTime

Returns the current absolute time, in seconds.

CAMediaTimingFunction

A function that defines the pacing of an animation as a timing curve.

CAMediaTiming

Methods that model a hierarchical timing system, allowing objects to map time between their parent and local time.

Beta Software

This documentation contains preliminary information about an API or technology in development. This information is subject to change, and software implemented according to this documentation should be tested with final operating system software.

Learn more about using Apple's beta software