<!--
{
  "availability" : [
    "iOS: 8.0.0 - 27.0.0",
    "iPadOS: 8.0.0 - 27.0.0",
    "macCatalyst: 13.1.0 - 27.0.0",
    "macOS: 10.10.0 - 27.0.0",
    "tvOS: 14.5.0 - 27.0.0",
    "visionOS: 1.0.0 - 27.0.0",
    "watchOS: 1.0.0 - 27.0.0"
  ],
  "documentType" : "symbol",
  "framework" : "AVFoundation",
  "identifier" : "/documentation/AVFoundation/AVSampleBufferAttachContentKey(_:_:_:)",
  "metadataVersion" : "0.1.0",
  "role" : "Function",
  "symbol" : {
    "kind" : "Function",
    "modules" : [
      "AVFoundation"
    ],
    "preciseIdentifier" : "c:@F@AVSampleBufferAttachContentKey"
  },
  "title" : "AVSampleBufferAttachContentKey(_:_:_:)"
}
-->

# AVSampleBufferAttachContentKey(_:_:_:)

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

```
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

A Boolean value that indicates whether the attachment is successful.

## Discussion

---

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)