Instance Method
decode(_:from:)
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 default property list format.
func decode<T>(_ type: T.Type, from data: Data) throws -> T where T : Decodable
Parameters
typeThe type of the value to decode.
dataThe data to decode from.
Return Value
A value of the requested type.
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.