Swifty
@objc
final public class Swifty : NSObject
Swifty: The main entry point to the networking infrastructure. Keeps track of the constraints and interceptors and services the requests with it’s URLSession while taking care of all the attributes of the network resource.
-
Swifty’s shared instance: It’s highly recommended you create your own Swifty instances with your customizations (Constraints, Interceptors) instead of using the shared instance.
Declaration
Swift
public static let shared: Swifty -
Initialize Swifty with the given URLSession, Constraints, and Request & Response Interceptors
The constraints and interceptors passed in these arguments will run in same order as passed in these arrays.
Declaration
Swift
public init(session: URLSession, constraints: [Constraint] = [], requestInterceptors: [RequestInterceptor] = [], responseInterceptors: [ResponseInterceptor] = [])Parameters
sessionURLSession
constraintsArray of Constraints.
requestInterceptorsArray of Request Interceptors.
responseInterceptorsArray of Response Interceptors.
-
Initialize Swifty with the given URLSessionConfiguration, Constraints, Request Interceptors & Response Interceptors
The constraints and interceptors passed in these arguments will run in same order as passed in these arrays.
Declaration
Swift
public convenience init(configuration: URLSessionConfiguration = URLSessionConfiguration.default, constraints: [Constraint] = [], requestInterceptors: [RequestInterceptor] = [], responseInterceptors: [ResponseInterceptor] = [], sessionMetricsDelegate: URLSessionTaskDelegate? = nil)Parameters
configurationURLSessionConfiguration (Defaults to URLSessionConfiguration.default)
constraintsArray of Constraints.
requestInterceptorsArray of Request Interceptors.
responseInterceptorsArray of Response Interceptors.
-
Adds a network resource to run on the Swifty Queue.
This is what is called internally when you use .load() method or any variant of the .load() method on a NetworkResource
Declaration
Swift
public func add(_ resource: NetworkResource, successBlock: @escaping SwiftySuccessBlock, failureBlock: @escaping SwiftyFailureBlock)Parameters
resourceNetworkResource
successBlockSwiftySuccessBlock
failureBlockSwiftyFailureBlock
-
Conforms Swifty’s shared instance to the WebServiceNetworkInterface protocol, making it easy to use directly with a WebService.
Declaration
Swift
public func loadResource(resource: NetworkResource, completion: @escaping (NetworkResponse) -> Void)
View on GitHub
Install in Dash
Swifty Class Reference