NetworkResponse
@objc
public class NetworkResponse : NSObject
The NetworkResponse class contains the Data, URLResponse, Error (if any) and possibly the serialized response for a given resource.
-
The HTTPURLResponse receieved from the network
Declaration
Swift
public var response: HTTPURLResponse?
-
The raw Data receieved from the network
Declaration
Swift
public var data: Data?
-
Error that response encountered (if any)
Declaration
Swift
public var error: NSError?
-
The result of the response serialization
Declaration
Swift
public var result: Any?
-
The ResponseParser that Swifty should use to serialize this repsonse
Declaration
Swift
public var parser: ResponseParser?
-
Initializes the network response
Declaration
Swift
public init(response: HTTPURLResponse? = nil, data: Data? = nil, error: NSError? = nil, parser: ResponseParser? = nil)
Parameters
response
HTTPURLResponse?
data
Data?
error
NSError?
parser
ResponseParser?
-
Forcefully succeeds the response, with the given response and data. This internally sets the error to nil. This is especially useful in response interceptors.
Declaration
Swift
public func succeed(response: HTTPURLResponse?, data: Data?)
Parameters
response
HTTPURLResponse?
data
Data?
-
Forcefully fails the response, with the given error. This is especially useful in response interceptors.
Declaration
Swift
public func fail(error: NSError)
Parameters
error
NSError.