Skip to content

Type MethodFoundationEssentials

decode(from:)

iOS 15.0+ iPadOS 15.0+ Mac Catalyst 15.0+ macOS 12.0+ tvOS 15.0+ watchOS 8.0+
Decodes a Swift value from the provided decoder, using a default implementation.
static func decode(from decoder: any Decoder) throws -> Self.Value

Parameters

decoder

The decoder to read data from.

Return Value

The decoded value.

Discussion

The default implementation calls down to the value’s Decodable.init(from:) method.

This method throws an error if reading from the decoder fails, or if the data read is corrupted or otherwise invalid.