<!--
{
  "documentType" : "article",
  "framework" : "Swift",
  "identifier" : "/documentation/Swift/KeyedEncodingContainer/KeyedEncodingContainerProtocol-Implementations",
  "metadataVersion" : "0.1.0",
  "role" : "collectionGroup",
  "title" : "KeyedEncodingContainerProtocol Implementations"
}
-->

# KeyedEncodingContainerProtocol Implementations

## Topics

### Instance Methods

[`func encode(Int128, forKey: Self.Key) throws`](/documentation/Swift/KeyedEncodingContainer/encode(_:forKey:)-8yufz)

Encodes the given value for the given key.

[`func encode(UInt128, forKey: Self.Key) throws`](/documentation/Swift/KeyedEncodingContainer/encode(_:forKey:)-vjhq)

Encodes the given value for the given key.

[`func encodeConditional<T>(T, forKey: Self.Key) throws`](/documentation/Swift/KeyedEncodingContainer/encodeConditional(_:forKey:)-2sxc0)

Encodes a reference to the given object only if it is encoded
unconditionally elsewhere in the payload (previously, or in the future).

[`func encodeIfPresent(UInt16?, forKey: Self.Key) throws`](/documentation/Swift/KeyedEncodingContainer/encodeIfPresent(_:forKey:)-1nn49)

Encodes the given value for the given key if it is not `nil`.

[`func encodeIfPresent(Double?, forKey: Self.Key) throws`](/documentation/Swift/KeyedEncodingContainer/encodeIfPresent(_:forKey:)-29g6g)

Encodes the given value for the given key if it is not `nil`.

[`func encodeIfPresent(UInt128?, forKey: Self.Key) throws`](/documentation/Swift/KeyedEncodingContainer/encodeIfPresent(_:forKey:)-2bjaq)

Encodes the given value for the given key if it is not `nil`.

[`func encodeIfPresent(Int32?, forKey: Self.Key) throws`](/documentation/Swift/KeyedEncodingContainer/encodeIfPresent(_:forKey:)-3afe0)

Encodes the given value for the given key if it is not `nil`.

[`func encodeIfPresent<T>(T?, forKey: Self.Key) throws`](/documentation/Swift/KeyedEncodingContainer/encodeIfPresent(_:forKey:)-3xv7m)

Encodes the given value for the given key if it is not `nil`.

[`func encodeIfPresent(Int16?, forKey: Self.Key) throws`](/documentation/Swift/KeyedEncodingContainer/encodeIfPresent(_:forKey:)-46r8i)

Encodes the given value for the given key if it is not `nil`.

[`func encodeIfPresent(Bool?, forKey: Self.Key) throws`](/documentation/Swift/KeyedEncodingContainer/encodeIfPresent(_:forKey:)-4p0ik)

Encodes the given value for the given key if it is not `nil`.

[`func encodeIfPresent(Int8?, forKey: Self.Key) throws`](/documentation/Swift/KeyedEncodingContainer/encodeIfPresent(_:forKey:)-4ws6m)

Encodes the given value for the given key if it is not `nil`.

[`func encodeIfPresent(UInt64?, forKey: Self.Key) throws`](/documentation/Swift/KeyedEncodingContainer/encodeIfPresent(_:forKey:)-6cvd3)

Encodes the given value for the given key if it is not `nil`.

[`func encodeIfPresent(String?, forKey: Self.Key) throws`](/documentation/Swift/KeyedEncodingContainer/encodeIfPresent(_:forKey:)-706xw)

Encodes the given value for the given key if it is not `nil`.

[`func encodeIfPresent(UInt32?, forKey: Self.Key) throws`](/documentation/Swift/KeyedEncodingContainer/encodeIfPresent(_:forKey:)-7m9z7)

Encodes the given value for the given key if it is not `nil`.

[`func encodeIfPresent(Int?, forKey: Self.Key) throws`](/documentation/Swift/KeyedEncodingContainer/encodeIfPresent(_:forKey:)-809zp)

Encodes the given value for the given key if it is not `nil`.

[`func encodeIfPresent(Int128?, forKey: Self.Key) throws`](/documentation/Swift/KeyedEncodingContainer/encodeIfPresent(_:forKey:)-836ib)

Encodes the given value for the given key if it is not `nil`.

[`func encodeIfPresent(Float?, forKey: Self.Key) throws`](/documentation/Swift/KeyedEncodingContainer/encodeIfPresent(_:forKey:)-954rq)

Encodes the given value for the given key if it is not `nil`.

[`func encodeIfPresent(UInt?, forKey: Self.Key) throws`](/documentation/Swift/KeyedEncodingContainer/encodeIfPresent(_:forKey:)-e1h9)

Encodes the given value for the given key if it is not `nil`.

[`func encodeIfPresent(UInt8?, forKey: Self.Key) throws`](/documentation/Swift/KeyedEncodingContainer/encodeIfPresent(_:forKey:)-n83l)

Encodes the given value for the given key if it is not `nil`.

[`func encodeIfPresent(Int64?, forKey: Self.Key) throws`](/documentation/Swift/KeyedEncodingContainer/encodeIfPresent(_:forKey:)-nej2)

Encodes the given value for the given key if it is not `nil`.

---

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)