---
title: "CMGetAttachment(_:key:attachmentModeOut:)"
framework: coremedia
role: symbol
role_heading: Function
path: "coremedia/cmgetattachment(_:key:attachmentmodeout:)"
---

# CMGetAttachment(_:key:attachmentModeOut:)

Returns an attachment from an attachment bearer object.

## Declaration

```swift
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 doc://com.apple.coremedia/documentation/CoreMedia/CMAttachmentModefor possible values. May be NULL.

## Return Value

Return Value The requested attachment object or NULL if not found.

## Discussion

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 CVBuffer, CMGetAttachment is equivalent to CVBufferCopyAttachment(_:_:_:).

## See Also

### Processing Attachments

- [CMCopyDictionaryOfAttachments(allocator:target:attachmentMode:)](coremedia/cmcopydictionaryofattachments(allocator:target:attachmentmode:).md)
- [CMSetAttachment(_:key:value:attachmentMode:)](coremedia/cmsetattachment(_:key:value:attachmentmode:).md)
- [CMSetAttachments(_:attachments:attachmentMode:)](coremedia/cmsetattachments(_:attachments:attachmentmode:).md)
- [CMRemoveAttachment(_:key:)](coremedia/cmremoveattachment(_:key:).md)
- [CMRemoveAllAttachments(_:)](coremedia/cmremoveallattachments(_:).md)
- [CMPropagateAttachments(_:destination:)](coremedia/cmpropagateattachments(_:destination:).md)
