iOS Developer Library — Pre-Release

Developer

QuartzCore Framework Reference CADisplayLink Class Reference

Options
Deployment Target:

On This Page
Language:

CADisplayLink

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

Inheritance


Conforms To


Import Statement


Swift

import QuartzCore

Objective-C

@import QuartzCore;

Availability


Available in iOS 3.1 and later.
  • Returns a new display link.

    Declaration

    Swift

    init!(target target: AnyObject!, selector sel: Selector) -> CADisplayLink

    Objective-C

    + (CADisplayLink *)displayLinkWithTarget:(id)target selector:(SEL)sel

    Parameters

    target

    An object to be notified when the screen should be updated.

    sel

    The method to call on the target.

    Return Value

    A newly constructed display link.

    Discussion

    The selector to be called on the target must be a method with the following signature:

    • - (void) selector:(CADisplayLink *)
    • sender
    • ;

    where sender is the display link returned by this method.

    The newly constructed display link retains the target.

    Import Statement

    Swift

    import QuartzCore

    Availability

    Available in iOS 3.1 and later.

  • Registers the display link with a run loop.

    Declaration

    Swift

    func addToRunLoop(_ runloop: NSRunLoop!, forMode mode: String!)

    Objective-C

    - (void)addToRunLoop:(NSRunLoop *)runloop forMode:(NSString *)mode

    Parameters

    runloop

    The run loop to associate with the display link.

    mode

    The mode in which to add the display link to the run loop. You may specify a custom mode or use one of the modes listed in NSRunLoop Class Reference.

    Discussion

    You can associate a display link with multiple input modes. While the run loop is executing in a mode you have specified, the display link notifies the target when new frames are required.

    The run loop retains the display link. To remove the display link from all run loops, send an invalidate message to the display link.

    Import Statement

    Swift

    import QuartzCore

    Availability

    Available in iOS 3.1 and later.

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

    Declaration

    Swift

    func removeFromRunLoop(_ runloop: NSRunLoop!, forMode mode: String!)

    Objective-C

    - (void)removeFromRunLoop:(NSRunLoop *)runloop forMode:(NSString *)mode

    Parameters

    runloop

    The run loop associated with the display link.

    mode

    The run loop mode in which the display link is running.

    Discussion

    The run loop releases the display link if it is no longer associated with any run modes.

    Import Statement

    Swift

    import QuartzCore

    Availability

    Available in iOS 3.1 and later.

  • Removes the display link from all run loop modes.

    Declaration

    Swift

    func invalidate()

    Objective-C

    - (void)invalidate

    Discussion

    Removing the display link from all run loop modes causes it to be released by the run loop. The display link also releases the target.

    Import Statement

    Swift

    import QuartzCore

    Availability

    Available in iOS 3.1 and later.

  • duration duration Property

    The time interval between screen refresh updates. (read-only)

    Declaration

    Swift

    var duration: CFTimeInterval { get }

    Objective-C

    @property(readonly, nonatomic) CFTimeInterval duration

    Discussion

    The value for duration is undefined before the target’s selector has been called at least once. Your application can calculate the amount of time it has to render each frame by multiplying duration by frameInterval.

    Import Statement

    Swift

    import QuartzCore

    Availability

    Available in iOS 3.1 and later.

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

    Declaration

    Swift

    var frameInterval: Int

    Objective-C

    @property(nonatomic) NSInteger frameInterval

    Discussion

    The default value is 1, which results in your application being notified at the refresh rate of the display. If the value is set to a value larger than 1, the display link notifies your application at a fraction of the native refresh rate. For example, setting the interval to 2 causes the display link to fire every other frame, providing half the frame rate.

    Setting this value to less than 1 results in undefined behavior and is a programmer error.

    Import Statement

    Swift

    import QuartzCore

    Availability

    Available in iOS 3.1 and later.

  • paused paused Property

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

    Declaration

    Swift

    var paused: Bool

    Objective-C

    @property(getter=isPaused, nonatomic) BOOL paused

    Discussion

    The default value is NOfalse. If YEStrue, the display link does not send notifications to the target.

    Import Statement

    Swift

    import QuartzCore

    Availability

    Available in iOS 3.1 and later.

  • timestamp timestamp Property

    The time value associated with the last frame that was displayed. (read-only)

    Declaration

    Swift

    var timestamp: CFTimeInterval { get }

    Objective-C

    @property(readonly, nonatomic) CFTimeInterval timestamp

    Discussion

    The target should use the value of this property to calculate what should be displayed in the next frame.

    Import Statement

    Swift

    import QuartzCore

    Availability

    Available in iOS 3.1 and later.