Required Instance Methodswift 6.0.3Swift

decodeIfPresent(_:)

Decodes a value of the given type, if present.

iOS
18.0+
macOS
15.0+
tvOS
18.0+
visionOS
2.0+
watchOS
11.0+
mutating func decodeIfPresent(_ type: Int128.Type) throws -> Int128?

Parameters

type

The type of value to decode.

Returns

A decoded value of the requested type, or nil if the value is a null value, or if there are no more elements to decode.

Throws

DecodingError.typeMismatch if the encountered encoded value is not convertible to the requested type.

This method returns nil if the container has no elements left to decode, or if the value is null. The difference between these states can be distinguished by checking isAtEnd.