---
title: "AVSampleBufferAttachContentKey(_:_:_:)"
framework: avfoundation
role: symbol
role_heading: Function
path: "avfoundation/avsamplebufferattachcontentkey(_:_:_:)"
---

# AVSampleBufferAttachContentKey(_:_:_:)

Attaches a content key to a sample buffer for the purpose of content decryption.

## Declaration

```swift
func AVSampleBufferAttachContentKey(_ sbuf: CMSampleBuffer, _ contentKey: AVContentKey, _ outError: NSErrorPointer) -> Bool
```

## Parameters

- `sbuf`: The sample buffer to which to attach the content key.
- `contentKey`: The content key to attach.
- `outError`: An error pointer. If a failure occurs, the system sets the pointer to an error object that describes the details of the failure.

## Return Value

Return Value A Boolean value that indicates whether the attachment is successful.

## See Also

### FairPlay streaming

- [AVContentKeySession](avfoundation/avcontentkeysession.md)
- [AVContentKeySessionDelegate](avfoundation/avcontentkeysessiondelegate.md)
- [AVContentKey](avfoundation/avcontentkey.md)
- [AVContentKeySpecifier](avfoundation/avcontentkeyspecifier.md)
- [AVContentKeyRequest](avfoundation/avcontentkeyrequest.md)
- [AVPersistableContentKeyRequest](avfoundation/avpersistablecontentkeyrequest.md)
- [AVContentKeyResponse](avfoundation/avcontentkeyresponse.md)
- [AVExternalContentProtectionStatus](avfoundation/avexternalcontentprotectionstatus.md)
