Skip to content

decodeData(__with_keyDecodingStrategy_dataDecodingStrategy_dateDecodingStrategy_)

MarcoDotIO edited this page Apr 25, 2023 · 1 revision

decodeData(_:with:keyDecodingStrategy:dataDecodingStrategy:dateDecodingStrategy:)

Decode a data object using JSONDecoder.decode().

public func decodeData<T: Decodable>(
        _ type: T.Type = T.self,
        with data: Data,
        keyDecodingStrategy: JSONDecoder.KeyDecodingStrategy = .useDefaultKeys,
        dataDecodingStrategy: JSONDecoder.DataDecodingStrategy = .deferredToData,
        dateDecodingStrategy: JSONDecoder.DateDecodingStrategy = .deferredToDate
    )

Parameters

  • type: The type of T that the data will decode to.
  • data: Data input object.
  • keyDecodingStrategy: Default is .useDefaultKeys.
  • dataDecodingStrategy: Default is .deferredToData.
  • dateDecodingStrategy: Default is .deferredToDate.

Returns

Decoded data of T type.

Types
Protocols
Global Variables
Global Functions
Extensions
Clone this wiki locally