Response

@objc public class Response: NSObject

A Response object represents the response from a network request.

  • A message for this response.

    Declaration

    Swift

    public var message: String = ""
  • Indicates if the request was successful or not.

    Declaration

    Swift

    public var success: Bool = true
  • If the response was unsuccessful this object will contain more information about the error.

    Declaration

    Swift

    public var error: DarkMatterError? = nil
  • The JSON data received with this response.

    Declaration

    Swift

    public var data: JSON? = nil
  • The HTTP headers received in the response.

    Declaration

    Swift

    public var headers: [String: String] = [:]
  • Initializes a successful Response object with the given message.

    Declaration

    Swift

    public init(message: String)

    Parameters

    message

    The message for this response.

  • Initializes a successful Response object with default values.

    Declaration

    Swift

    public override init()
  • Initializes a Response object from the given Alamofire DataResponse object. If the result.value object can’t be converted to a JSON object this response will be considered unsuccessful.

    Declaration

    Swift

    public init(response: DataResponse<Any>)

    Parameters

    response

    The Alamofire DataResponse object to parse.

  • Initializes a successful Response object with the given JSON data.

    Declaration

    Swift

    public init(data: [String: AnyObject])

    Parameters

    data

    The JSON object for the response.

  • Initializes a Response object with the given values.

    Declaration

    Swift

    public init(success: Bool, message: String, error: DarkMatterError?, headers: [String: String], data: JSON?)

    Parameters

    success

    true if this is a successful response.

    message

    The message for this response.

    error

    The error that occurred if the response was unsuccessful.

    headers

    The HTTP headers received with the response.

    data

    The JSON data received with the response.