<!--
{
  "availability" : [
    "iOS: 4.0.0 -",
    "iPadOS: 4.0.0 -",
    "macCatalyst: 13.1.0 -",
    "macOS: 10.7.0 -",
    "tvOS: 9.0.0 -",
    "visionOS: 1.0.0 -",
    "watchOS: 6.0.0 -"
  ],
  "documentType" : "symbol",
  "framework" : "CoreMedia",
  "identifier" : "/documentation/CoreMedia/CMGetAttachment(_:key:attachmentModeOut:)",
  "metadataVersion" : "0.1.0",
  "role" : "Function",
  "symbol" : {
    "kind" : "Function",
    "modules" : [
      "Core Media"
    ],
    "preciseIdentifier" : "c:@F@CMGetAttachment"
  },
  "title" : "CMGetAttachment(_:key:attachmentModeOut:)"
}
-->

# CMGetAttachment(_:key:attachmentModeOut:)

Returns an attachment from an attachment bearer object.

```
func CMGetAttachment(_ target: CMAttachmentBearer, key: CFString, attachmentModeOut: UnsafeMutablePointer<CMAttachmentMode>?) -> CFTypeRef?
```

## Parameters

`target`

Specifies the `CMAttachmentBearer` whose attachment you want to retrieve.

`key`

Key in the form of a `CFString` identifying the desired attachment.

`attachmentModeOut`

On output, `attachmentMode` points to the mode of the attachment. See [`CMAttachmentMode`](/documentation/CoreMedia/CMAttachmentMode)for possible values. May be `NULL`.

## Return Value

The requested attachment object or `NULL` if not found.

## Discussion

You can attach any Core Foundation object to a `CMAttachmentBearer` to store additional information. `CMGetAttachment` retrieves an attachment identified by a key. Given a <doc://com.apple.documentation/documentation/CoreVideo/CVBuffer>, `CMGetAttachment` is equivalent to <doc://com.apple.documentation/documentation/CoreVideo/CVBufferCopyAttachment(_:_:_:)>.

---

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)