KeyedEncodingContainer

public extension KeyedEncodingContainer

KeyedEncodingContainer+Decodable adds the ability to encode an array

Author

Adamas

Version

1.6.0

Date

08/08/2019
  • Encode an array if presented

    Throws

    DecodingError.typeMismatch if the encountered stored value is not an unkeyed container or a contained object doesn’t match the object type.

    Throws

    DecodingError.valueNotFound if the encountered encoded value is null, or of there are no more values to decode.

    Declaration

    Swift

    mutating func encodeArrayIfPresent<O>(_ array: [O]?, for key: K) throws where O : Encodable

    Parameters

    key

    The coding key

    Return Value

    An array of objects

  • Encode an array

    Throws

    DecodingError.typeMismatch if the encountered stored value is not an unkeyed container or a contained object doesn’t match the object type.

    Throws

    DecodingError.valueNotFound if the encountered encoded value is null, or of there are no more values to decode.

    Declaration

    Swift

    mutating func encodeArray<O>(_ array: [O]?, for key: K) throws where O : Encodable

    Parameters

    key

    The coding key

    Return Value

    An array of objects