Contents

decodeTopLevelDecodable(_:forKey:)

Decodes a top-level decodable value associated with a given key.

Declaration

@nonobjc func decodeTopLevelDecodable<T>(_ type: T.Type, forKey key: String) throws -> T? where T : Decodable

Parameters

  • type:

    The type of the value to decode.

  • key:

    The key in the archive associated with the value to decode.

Discussion

If the archive is not a valid property list, this method throws the DecodingError.dataCorrupted(_:) error. If a value within the archive fails to decode, this method throws the corresponding error.

See Also

Decoding Data