---
title: "encode(with:)"
framework: avfoundation
role: symbol
role_heading: Instance Method
path: "avfoundation/avcaptionregion/encode(with:)"
---

# encode(with:)

Encodes the region using the specified encoder.

## Declaration

```swift
func encode(with encoder: NSCoder)
```

## Parameters

- `encoder`: An encoder instance to use.

## Discussion

Discussion This method throws an exception if the caption region’s size has different units for width and height, or if the units are unrecognizeable.

## See Also

### Processing regions

- [mutableCopy(with:)](avfoundation/avcaptionregion/mutablecopy(with:).md)
- [isEqual(_:)](avfoundation/avcaptionregion/isequal(_:).md)
