Index

RBNetworkOperation.swift

Protocols

Classes


RBNetworkOperation

A network operation.

Properties

A delegate to receive events.
public weak var delegate RBNetworkOperationDelegate? { get set }

The original request.
public var originalRequest URLRequest? { get }

The current request.
public var currentRequest URLRequest? { get }

The current state of the underlying URLSessionTask.
public var state URLSessionTask { get }

The underlying response object, nil until completion.
public var response URLResponse? { get }

The underlying HTTP response object, nil until completion or if the request was not of type HTTP.
public var httpResponse HTTPURLResponse? { get }

The response data, nil until completion.
public var data Data? { get }

The HTTP status code if available otherwise 0.
public var httpStatusCode Int { get }

The metrics for this operation nil until completion.
public var metrics URLSessionTaskMetrics? { get set }

Functions

public func resume()

public func suspend()

public func cancel()

Deserializes the data property to a JSON object.
@returns The JSON as dictionary or an array of dictionaries as appropriate or nil if data is empty or the response was invalid.
public func dataAsJson() -> Any?

Deserializes the data property to a typed RBJsonObject object.
@returns The JSON as a specific RBJsonObject instance or nil if data is empty or the response was invalid.
public func dataToJson<T: RBJsonObject>() -> [T]?

Deserializes the data property to a typed RBJsonObject object.
@param jsonPath : Optional json path to first follow before deserialisation of the json to the specified type occurs e.g. data.results[0].
@returns The JSON as a specific RBJsonObject instance or nil if data is empty or the response was invalid.
public func dataToJson<T: RBJsonObject>(jsonPath: String?) -> [T]?

Deserializes the data property to a typed array of RBJsonObject objects.
@returns The JSON as an array of specific RBJsonObject instances or nil if data is empty or the response was invalid.
public func dataToJson<T: RBJsonObject>() -> T?

Deserializes the data property to a typed array of RBJsonObject objects.
@param jsonPath : Optional json path to first follow before deserialisation of the json to the specified type occurs e.g. data.results[0].
@returns The JSON as an array of specific RBJsonObject instances or nil if data is empty or the response was invalid.
public func dataToJson<T: RBJsonObject>(jsonPath: String?) -> T?

Deserializes the data property to a typed array of RBJsonObject objects.
@param encoding : Optional string encoding to use. Default = UTF8.
@returns The data as a decoded string or nil if data is empty or the response was invalid.
public func dataToString(encoding: String.Encoding = String.Encoding.utf8) -> String?