NetworkResult

protocol NetworkResult

This protocol defines the default layout of the NetworkResult after a NetworkOperation has completed. It allows for room to grow and any custom implementation to be provided

  • A network status code often used to hold a value such as a 200 or 404 as found on typical HTTP operations.

    Declaration

    Swift

    var code: Int { get }
  • Any data associated with the result; can be in any format

    Declaration

    Swift

    var data: Data? { get }
  • A status flag indicating whether the result was successful, a failure or in progress

    Declaration

    Swift

    var status: NetworkStatus { get }
  • stringFormat Default implementation

    A shorthand alternative to the Data representation; the default implementation of this getter returns a String(data: data, encoding: .utf8) version of the internal .data property

    Default Implementation

    Default implementation of the variable simply converts the internal data value to a String using String(date:,encoding:). If this behavior isn’t sufficient overload the variable with a different getter

    Declaration

    Swift

    var stringFormat: String? { get }