---
title: "attach(_:to:)"
framework: avfoundation
role: symbol
role_heading: Instance Method
path: "avfoundation/avasynchronousvideocompositionrequest/attach(_:to:)"
---

# attach(_:to:)

Associates the pixel buffer with the specified spatial configuration.

## Declaration

```swift
func attach(_ spatialVideoConfiguration: AVSpatialVideoConfiguration, to pixelBuffer: inout CVMutablePixelBuffer) throws
```

## Parameters

- `spatialVideoConfiguration`: The spatial configuration to associate with the pixel buffer.
- `pixelBuffer`: The pixel buffer to associate with the spatial configuration. NOTE: The spatial configuration must be one of the spatial configurations specified in the AVVideoComposition’s spatialConfigurations property. An exception will be thrown otherwise. NOTE: All pixel buffers from the custom compositor must be associated with the same spatial configuration. An exception will be thrown otherwise. Specify a value of .nonSpatial for spatialVideoConfiguration to indicate the video is not spatial, but note that a .nonSpatial configuration must be in the AVVideoComposition/spatialConfigurations property or an exception will be thrown.

## See Also

### Accessing source data

- [sourceFrame(byTrackID:)](avfoundation/avasynchronousvideocompositionrequest/sourceframe(bytrackid:).md)
- [sourceReadOnlyPixelBuffer(byTrackID:)](avfoundation/avasynchronousvideocompositionrequest/sourcereadonlypixelbuffer(bytrackid:).md)
- [sourceReadySampleBuffer(byTrackID:)](avfoundation/avasynchronousvideocompositionrequest/sourcereadysamplebuffer(bytrackid:).md)
- [sourceSampleBuffer(byTrackID:)](avfoundation/avasynchronousvideocompositionrequest/sourcesamplebuffer(bytrackid:).md)
- [sourceSampleDataTrackIDs](avfoundation/avasynchronousvideocompositionrequest/sourcesampledatatrackids-3yiab.md)
- [sourceTaggedDynamicBuffers(byTrackID:)](avfoundation/avasynchronousvideocompositionrequest/sourcetaggeddynamicbuffers(bytrackid:).md)
- [sourceTimedMetadata(byTrackID:)](avfoundation/avasynchronousvideocompositionrequest/sourcetimedmetadata(bytrackid:).md)
- [sourceTrackIDs](avfoundation/avasynchronousvideocompositionrequest/sourcetrackids.md)
