<!--
{
  "availability" : [
    "iOS: 17.0.0 -",
    "iPadOS: 17.0.0 -",
    "macCatalyst: 17.0.0 -",
    "macOS: 14.0.0 -",
    "tvOS: 17.0.0 -",
    "visionOS: 1.0.0 -"
  ],
  "documentType" : "symbol",
  "framework" : "QuartzCore",
  "identifier" : "/documentation/QuartzCore/CAMetalDisplayLink/add(to:forMode:)",
  "metadataVersion" : "0.1.0",
  "role" : "Instance Method",
  "symbol" : {
    "kind" : "Instance Method",
    "modules" : [
      "Core Animation"
    ],
    "preciseIdentifier" : "c:objc(cs)CAMetalDisplayLink(im)addToRunLoop:forMode:"
  },
  "title" : "add(to:forMode:)"
}
-->

# add(to:forMode:)

Registers the display link with a run loop.

```
func add(to runloop: RunLoop, forMode mode: RunLoop.Mode)
```

## Parameters

`runloop`

A run loop instance the method associates with the display link.

`mode`

A run loop mode for the display link.

## Discussion

You can associate the display link with any of the <doc://com.apple.documentation/documentation/Foundation/RunLoop> modes, multiple input modes, or a custom mode. When the run loop is in `mode`, the display link notifies its delegate when the system prepares the next frame.

You can remove the display link from a run loop by calling [`remove(from:forMode:)`](/documentation/QuartzCore/CAMetalDisplayLink/remove(from:forMode:)), or from all run loops with [`invalidate()`](/documentation/QuartzCore/CAMetalDisplayLink/invalidate()).

---

Copyright &copy; 2026 Apple Inc. All rights reserved. | [Terms of Use](https://www.apple.com/legal/internet-services/terms/site.html) | [Privacy Policy](https://www.apple.com/privacy/privacy-policy)