<!--
{
  "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/CVAttachmentValueRepresentable",
  "metadataVersion" : "0.1.0",
  "role" : "Protocol",
  "symbol" : {
    "kind" : "Protocol",
    "modules" : [
      "Core Video"
    ],
    "preciseIdentifier" : "s:9CoreVideo30CVAttachmentValueRepresentableP"
  },
  "title" : "CVAttachmentValueRepresentable"
}
-->

# CVAttachmentValueRepresentable

Allows Swift types to be used as buffer attachment value.

```
protocol CVAttachmentValueRepresentable
```

## Overview

A type conforming to this protocol can be used as value for an attachment key. The [`CVAttachmentRawValue`](/documentation/CoreVideo/CVAttachmentRawValue) type
facilitates conversion to and from raw attachment values. Conformances of standard Swift type to this protocol are
provided in CoreVideo framework. Implementing this protocol for a custom struct is as simple as:

```swift
struct MyStruct {
	var number: Int
	var tags: [String]
}

extension MyStruct: CVAttachmentValueRepresentable {
	static func makeFromRawAttachmentValue(_ repr: CVAttachmentRawValue) -> Self? {
		guard let number: Int = repr["number"], tags: [String] = repr["tags"] else { return nil }
		return .init(number: number, tags: tags)
	}

	var rawAttachmentValueRepresentation: CVAttachmentRawValue {
		["number": self.number, "tags": self.tags]
	}
}
```

Default implementation is provided for `RawRepresentable` protocol where RawValue conforms to this protocol. This
allow enumeration with raw values to conform to [`CVAttachmentValueRepresentable`](/documentation/CoreVideo/CVAttachmentValueRepresentable) protocol without a custom
implementation.

## Topics

### Instance Properties

[`var rawAttachmentValueRepresentation: CVAttachmentRawValue`](/documentation/CoreVideo/CVAttachmentValueRepresentable/rawAttachmentValueRepresentation)

### Type Methods

[`static func makeFromRawAttachmentValue(CVAttachmentRawValue) -> Self?`](/documentation/CoreVideo/CVAttachmentValueRepresentable/makeFromRawAttachmentValue(_:))

## Relationships

### Conforming Types

[`CVImageTransferFunction`](/documentation/CoreVideo/CVImageTransferFunction)

[`CVImagePixelAspectRatio`](/documentation/CoreVideo/CVImagePixelAspectRatio)

[`CVSenselSitingOffsets`](/documentation/CoreVideo/CVSenselSitingOffsets)

[`CVSenselArrayPattern`](/documentation/CoreVideo/CVSenselArrayPattern)

[`ChromaSubsampling`](/documentation/CoreVideo/CVImageChromaField/ChromaSubsampling)

[`CVImageYCbCrMatrix`](/documentation/CoreVideo/CVImageYCbCrMatrix)

[`FieldLocation-swift.enum`](/documentation/CoreVideo/CVImageChromaField/FieldLocation-swift.enum)

[`CVImageFieldDetail`](/documentation/CoreVideo/CVImageFieldDetail)

[`SampleLocation`](/documentation/CoreVideo/CVImageChromaField/SampleLocation)

[`CVImageColorPrimaries`](/documentation/CoreVideo/CVImageColorPrimaries)

[`CVImageCleanAperture`](/documentation/CoreVideo/CVImageCleanAperture)

[`CVImageStereoDisplayMaskRectangle`](/documentation/CoreVideo/CVImageStereoDisplayMaskRectangle)

[`CVImageDisplayMaskRectangle`](/documentation/CoreVideo/CVImageDisplayMaskRectangle)

[`CVImageLogTransferFunction`](/documentation/CoreVideo/CVImageLogTransferFunction)

[`CVImageAlphaChannelMode`](/documentation/CoreVideo/CVImageAlphaChannelMode)

[`CVProResRawMetadata`](/documentation/CoreVideo/CVProResRawMetadata)

[`RecommendedCrop-swift.struct`](/documentation/CoreVideo/CVProResRawMetadata/RecommendedCrop-swift.struct)

[`CVImageChromaField`](/documentation/CoreVideo/CVImageChromaField)

---

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)