Network - Kelmatou/iOSTools GitHub Wiki
Requester
Nested Types
enum AccessMethod: String {
case GET = "GET"
case POST = "POST"
case PUT = "PUT"
case DELETE = "DELETE"
}
Statics
func request(_ method: AccessMethod, url: String, headers: [String : String]? = nil, body: String? = nil, handler: @escaping (Data?, GenericError?) -> Void)
func requestText(_ method: AccessMethod, url: String, headers: [String : String]? = nil, body: String? = nil, handler: @escaping (String?, GenericError?) -> Void)
func requestImage(_ method: AccessMethod, url: String, headers: [String : String]? = nil, body: String? = nil, handler: @escaping (UIImage?, GenericError?) -> Void)
Definitions
-
static func request(_ method: AccessMethod, url: String, headers: [String : String]? = nil, body: String? = nil, handler: @escaping (Data?, GenericError?) -> Void)
: Make an HTTP request with a specified access method to an url, using optional headers and body. Response is transmitted with handler. If an error occurred, look at the GenericError object provided. See GenericError.
-
static func requestText(_ method: AccessMethod, url: String, headers: [String : String]? = nil, body: String? = nil, handler: @escaping (String?, GenericError?) -> Void)
: Make an HTTP text request with a specified access method to an url, using optional headers and body. Response is transmitted with handler as a String. If an error occurred, look at the GenericError object provided. See GenericError.
-
static func requestImage(_ method: AccessMethod, url: String, headers: [String : String]? = nil, body: String? = nil, handler: @escaping (UIImage?, GenericError?) -> Void)
: Make an HTTP image request with a specified access method to an url, using optional headers and body. Response is transmitted with handler as an UIImage. If an error occurred, look at the GenericError object provided. See GenericError.
Reachability
Delegates
protocol ReachabilityDelegate: class {
func reachabilityStatusChanged(newStatus: Reachability.Status)
}
Nested Types
enum Status: String {
case Disconnected = "Disconnected"
case WifiConnection = "WifiConnection"
case CellularConnection = "CellularConnection"
case Unknown = "Unknown"
}
Properties
weak var delegate: ReachabilityDelegate?
var autoUpdate: Bool
var refreshDelay: Int
var currentStatus: Status
Inits
init(autoUpdate: Bool = false)
Methods
func isConnectionAvailable() -> Bool
Statics
func isConnectionAvailable() -> Bool
Definitions
-
weak var delegate: ReachabilityDelegate?
: Reachability delegate, assign it to your class to receive notifications.
-
var autoUpdate: Bool
: If true, will periodically (see refreshDelay) update connection status. Default value is true.
-
var refreshDelay: Int
: Determines the frequency of connection status update. A new update will start every refreshDelay seconds. Default value is 5 seconds.
-
var currentStatus: Status
: The connection status from last update.
-
init(autoUpdate: Bool = true)
: Create a new Reachability object. Can also set initial autoUpdate value.
-
func isConnectionAvailable() -> Bool
: Update currentStatus and return true if device has an internet connection available.
-
static func isConnectionAvailable() -> Bool
: Return true if device has an internet connection available.