Required Instance Methodswift 6.0.1Swift
encodeIfPresent(_:forKey:)
Encodes the given value for the given key if it is not nil
.
- iOS
- 18.0+
- macOS
- 15.0+
- tvOS
- 18.0+
- visionOS
- 2.0+
- watchOS
- 11.0+
mutating func encodeIfPresent(_ value: Int128?, forKey key: Self.Key) throws
Parameters
Throws
EncodingError.invalidValue
if the given value is invalid in the current context for this format.
Other requirements
View members
Hide members
This section is hidden by default because it contains too many (41) members.
Type members
Instance members
var codingPath: [any CodingKey]
The path of coding keys taken to get to this point in encoding.
func encode(String, forKey: Self.Key
) throws Encodes the given value for the given key.
func encode(Bool, forKey: Self.Key
) throws Encodes the given value for the given key.
func encode(Double, forKey: Self.Key
) throws Encodes the given value for the given key.
func encode(Float, forKey: Self.Key
) throws Encodes the given value for the given key.
func encode(Int, forKey: Self.Key
) throws Encodes the given value for the given key.
func encode(UInt, forKey: Self.Key
) throws Encodes the given value for the given key.
func encode<T>(T, forKey: Self.Key
) throws Encodes the given value for the given key.
func encode(Int8, forKey: Self.Key
) throws Encodes the given value for the given key.
func encode(Int16, forKey: Self.Key
) throws Encodes the given value for the given key.
func encode(Int32, forKey: Self.Key
) throws Encodes the given value for the given key.
func encode(Int64, forKey: Self.Key
) throws Encodes the given value for the given key.
func encode(UInt8, forKey: Self.Key
) throws Encodes the given value for the given key.
func encode(Int128, forKey: Self.Key
) throws Encodes the given value for the given key.
func encode(UInt16, forKey: Self.Key
) throws Encodes the given value for the given key.
func encode(UInt32, forKey: Self.Key
) throws Encodes the given value for the given key.
func encode(UInt64, forKey: Self.Key
) throws Encodes the given value for the given key.
func encode(UInt128, forKey: Self.Key
) throws Encodes the given value for the given key.
func encodeConditional<T>(T, forKey: Self.Key
) throws Encodes a reference to the given object only if it is encoded unconditionally elsewhere in the payload (previously, or in the future).
func encodeIfPresent(String?, forKey: Self.Key
) throws Encodes the given value for the given key if it is not
nil
.func encodeIfPresent(Bool?, forKey: Self.Key
) throws Encodes the given value for the given key if it is not
nil
.func encodeIfPresent(Double?, forKey: Self.Key
) throws Encodes the given value for the given key if it is not
nil
.func encodeIfPresent(Float?, forKey: Self.Key
) throws Encodes the given value for the given key if it is not
nil
.func encodeIfPresent(Int?, forKey: Self.Key
) throws Encodes the given value for the given key if it is not
nil
.func encodeIfPresent(UInt?, forKey: Self.Key
) throws Encodes the given value for the given key if it is not
nil
.func encodeIfPresent<T>(T?, forKey: Self.Key
) throws Encodes the given value for the given key if it is not
nil
.func encodeIfPresent(Int8?, forKey: Self.Key
) throws Encodes the given value for the given key if it is not
nil
.func encodeIfPresent(Int16?, forKey: Self.Key
) throws Encodes the given value for the given key if it is not
nil
.func encodeIfPresent(Int32?, forKey: Self.Key
) throws Encodes the given value for the given key if it is not
nil
.func encodeIfPresent(Int64?, forKey: Self.Key
) throws Encodes the given value for the given key if it is not
nil
.func encodeIfPresent(UInt8?, forKey: Self.Key
) throws Encodes the given value for the given key if it is not
nil
.func encodeIfPresent(UInt16?, forKey: Self.Key
) throws Encodes the given value for the given key if it is not
nil
.func encodeIfPresent(UInt32?, forKey: Self.Key
) throws Encodes the given value for the given key if it is not
nil
.func encodeIfPresent(UInt64?, forKey: Self.Key
) throws Encodes the given value for the given key if it is not
nil
.func encodeIfPresent(UInt128?, forKey: Self.Key
) throws Encodes the given value for the given key if it is not
nil
.func encodeNil(forKey: Self.Key
) throws Encodes a null value for the given key.
func nestedContainer<NestedKey>(keyedBy: NestedKey.Type, forKey: Self.Key
) -> KeyedEncodingContainer<NestedKey> Stores a keyed encoding container for the given key and returns it.
func nestedUnkeyedContainer(forKey: Self.Key
) -> any UnkeyedEncodingContainer Stores an unkeyed encoding container for the given key and returns it.
func superEncoder(
) -> any Encoder Stores a new nested container for the default
super
key and returns a new encoder instance for encodingsuper
into that container.func superEncoder(forKey: Self.Key
) -> any Encoder Stores a new nested container for the given key and returns a new encoder instance for encoding
super
into that container.
Citizens in Swift
Default implementations
func encodeIfPresent(String?, forKey: Self.Key
) throws func encodeIfPresent(Bool?, forKey: Self.Key
) throws func encodeIfPresent(Double?, forKey: Self.Key
) throws func encodeIfPresent(Float?, forKey: Self.Key
) throws func encodeIfPresent(Int?, forKey: Self.Key
) throws func encodeIfPresent(UInt?, forKey: Self.Key
) throws func encodeIfPresent<T>(T?, forKey: Self.Key
) throws func encodeIfPresent(Int8?, forKey: Self.Key
) throws func encodeIfPresent(Int16?, forKey: Self.Key
) throws func encodeIfPresent(Int32?, forKey: Self.Key
) throws func encodeIfPresent(Int64?, forKey: Self.Key
) throws func encodeIfPresent(UInt8?, forKey: Self.Key
) throws func encodeIfPresent(Int128?, forKey: Self.Key
) throws func encodeIfPresent(UInt16?, forKey: Self.Key
) throws func encodeIfPresent(UInt32?, forKey: Self.Key
) throws func encodeIfPresent(UInt64?, forKey: Self.Key
) throws func encodeIfPresent(UInt128?, forKey: Self.Key
) throws