---
title: "encode(_:forKey:)"
framework: foundation
role: symbol
role_heading: Instance Method
path: "foundation/nscoder/encode(_:forkey:)-44zsc"
---

# encode(_:forKey:)

Encodes edge inset data and associates it with the specified key in the coder’s archive.

## Declaration

```swift
func encode(_ insets: UIEdgeInsets, forKey key: String)
```

## Parameters

- `insets`: The edge insets data to encode.
- `key`: The key identifying the data.

## Discussion

Discussion When decoding the data from the archive, you pass the value in the key parameter to the corresponding decodeUIEdgeInsets(forKey:) method to retrieve the data.

## See Also

### Related Documentation

- [decodeUIEdgeInsets(forKey:)](foundation/nscoder/decodeuiedgeinsets(forkey:).md)

### Encoding Geometry-Based Data

- [encode(_:forKey:)](foundation/nscoder/encode(_:forkey:)-29jyx.md)
- [encode(_:forKey:)](foundation/nscoder/encode(_:forkey:)-7z9kc.md)
- [encode(_:forKey:)](foundation/nscoder/encode(_:forkey:)-10qhm.md)
- [encode(_:forKey:)](foundation/nscoder/encode(_:forkey:)-6wq3n.md)
- [encode(_:forKey:)](foundation/nscoder/encode(_:forkey:)-26fxa.md)
- [encode(_:forKey:)](foundation/nscoder/encode(_:forkey:)-7oo2n.md)
- [encode(_:forKey:)](foundation/nscoder/encode(_:forkey:)-9d1qy.md)
