Data

struct Data : ReferenceConvertible, Equatable, Hashable, RandomAccessCollection, MutableCollection, RangeReplaceableCollection
  • A Unicode string value representation of the data.

    This computed instance property renders its associated Data value into a Unicode string. This can be useful when reviewing the content of a byte buffer, such as when downloading a JSON object from a REST API service.

    Declaration

    Swift

    var stringDescription: String { get }
  • Directly decodes any Decodable object using any given decoder conforming to the AnyDecoder protocol.

    This generic instance method returns a type-inferred value, decoded from an object adopting the Decodable protocol. The decoder used must conform to the AnyDecoder protocol but is of type JSONDecoder by default.

    Declaration

    Swift

    func decoded<T: Decodable>(using decoder: AnyDecoder = JSONDecoder())
        throws -> T

    Parameters

    decoder

    A decoder conforming to the AnyDecoder protocol.

    Return Value

    A decoded object adopting the Decodable protocol.