<!--
{
  "availability" : [
    "iOS: 27.0.0 -",
    "iPadOS: 27.0.0 -",
    "macCatalyst: 27.0.0 -",
    "macOS: 27.0.0 -",
    "tvOS: 27.0.0 -",
    "visionOS: 27.0.0 -",
    "watchOS: 27.0.0 -"
  ],
  "documentType" : "symbol",
  "framework" : "CoreVideo",
  "identifier" : "/documentation/CoreVideo/CVAttachmentContainer",
  "metadataVersion" : "0.1.0",
  "role" : "Structure",
  "symbol" : {
    "kind" : "Structure",
    "modules" : [
      "Core Video"
    ],
    "preciseIdentifier" : "s:9CoreVideo21CVAttachmentContainerV"
  },
  "title" : "CVAttachmentContainer"
}
-->

# CVAttachmentContainer

Provides storage for buffer attachments independent of the buffer lifetime

```
@dynamicMemberLookup struct CVAttachmentContainer<Keys> where Keys : CVAttachmentKeyDefinitions
```

## Overview

This object can be used to hold a copy of all buffer attachments. The attachment values can be accessed as
properties of this object similar to [`CVAttachmentAccess`](/documentation/CoreVideo/CVAttachmentAccess).

## Topics

### Initializers

[`init(propagated: [String : any CVAttachmentValueRepresentable], nonPropagated: [String : any CVAttachmentValueRepresentable])`](/documentation/CoreVideo/CVAttachmentContainer/init(propagated:nonPropagated:))

### Instance Methods

[`func attachedMode(of: KeyPath<Keys.Type, CVAttachmentKeyDefinition<some CVAttachmentModePreference, some CVAttachmentValueRepresentable>>) -> CVAttachmentMode?`](/documentation/CoreVideo/CVAttachmentContainer/attachedMode(of:)-4qvrl)

Returns the propagation mode of a stored attachment you identify with a key path to a key definition, without retrieving the value.

[`func attachedMode(of: KeyPath<Keys.Type, CVAttachmentKeyDefinitionWithDefault<some CVAttachmentModePreference, some CVAttachmentValueRepresentable & Equatable & Sendable>>) -> CVAttachmentMode?`](/documentation/CoreVideo/CVAttachmentContainer/attachedMode(of:)-7vger)

Returns the propagation mode of a stored attachment you identify with a key path to a key definition that supplies a default, without retrieving it.

[`func attachedMode(of: String) -> CVAttachmentMode?`](/documentation/CoreVideo/CVAttachmentContainer/attachedMode(of:)-p6ms)

Returns the propagation mode of a stored attachment you identify by its raw key string, without retrieving the value.

[`func removeAll()`](/documentation/CoreVideo/CVAttachmentContainer/removeAll())

Removes all attachments.

[`func update(from: CVAttachmentContainer<Keys>)`](/documentation/CoreVideo/CVAttachmentContainer/update(from:))

Updates propagated and non-propagated attachment values using the provided container.

### Subscripts

[`subscript<Value>(String, as _: Value.Type) -> (value: Value, mode: CVAttachmentMode)?`](/documentation/CoreVideo/CVAttachmentContainer/subscript(_:as:))

Get or set attachment value associated with a string key

[`subscript<ModePreference, Value>(dynamicMember _: KeyPath<Keys.Type, CVAttachmentKeyDefinition<ModePreference, Value>>) -> Value?`](/documentation/CoreVideo/CVAttachmentContainer/subscript(dynamicMember:)-3qlmo)

Get or set attachment value as a property of this object.

[`subscript<ModePreference, Value>(dynamicMember _: KeyPath<Keys.Type, CVAttachmentKeyDefinitionWithDefault<ModePreference, Value>>) -> Value`](/documentation/CoreVideo/CVAttachmentContainer/subscript(dynamicMember:)-8zxr1)

Get or set attachment value as a property of this object with default value.

[`subscript<ModePreference, Value>(dynamicMember _: KeyPath<Keys.Type, CVAttachmentCompositeKeyDefinition<ModePreference, Value>>) -> Value?`](/documentation/CoreVideo/CVAttachmentContainer/subscript(dynamicMember:)-fjtq)

Get or set composite attachment value as a property of this object.

## Relationships

### Conforms To

[`SendableMetatype`](/documentation/Swift/SendableMetatype)

[`Sendable`](/documentation/Swift/Sendable)

[`Equatable`](/documentation/Swift/Equatable)

---

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)