Skip to content

Instance Method

decode(_:from:format:)

iOS 8.0+ iPadOS 8.0+ Mac Catalyst 8.0+ macOS 10.10+ tvOS 9.0+ watchOS 2.0+
Returns a value of the specified type by decoding a property list using the supplied format.
func decode<T>(_ type: T.Type, from data: Data, format: inout PropertyListDecoder.PropertyListFormat) throws -> T where T : Decodable

Parameters

type

The type of the value to decode.

data

The data to decode from.

format

The parsed property list format.

Return Value

A value of the requested type along with the detected format of the property list.

Discussion

Throws

DecodingError.dataCorrupted if values requested from the payload are corrupted, or if the given data is not a valid property list.

Throws

An error if any value throws an error during decoding.