Functions

The following functions are available globally.

  • Creates a request using the shared manager instance for the specified method, URL string, parameters, and parameter encoding.

    Declaration

    Swift

    public func request(
        method: Method,
        _ URLString: URLStringConvertible,
        parameters: [String: AnyObject]? = nil,
        encoding: ParameterEncoding = .URL,
        headers: [String: String]? = nil)
        -> Request

    Parameters

    method

    The HTTP method.

    URLString

    The URL string.

    parameters

    The parameters. nil by default.

    encoding

    The parameter encoding. .URL by default.

    headers

    The HTTP headers. nil by default.

    Return Value

    The created request.

  • Creates a request using the shared manager instance for the specified URL request.

    If startRequestsImmediately is true, the request will have resume() called before being returned.

    Declaration

    Swift

    public func request(URLRequest: URLRequestConvertible) -> Request

    Parameters

    URLRequest

    The URL request

    Return Value

    The created request.

  • Creates an upload request using the shared manager instance for the specified method, URL string, and file.

    Declaration

    Swift

    public func upload(
        method: Method,
        _ URLString: URLStringConvertible,
        headers: [String: String]? = nil,
        file: NSURL)
        -> Request

    Parameters

    method

    The HTTP method.

    URLString

    The URL string.

    headers

    The HTTP headers. nil by default.

    file

    The file to upload.

    Return Value

    The created upload request.

  • Creates an upload request using the shared manager instance for the specified URL request and file.

    Declaration

    Swift

    public func upload(URLRequest: URLRequestConvertible, file: NSURL) -> Request

    Parameters

    URLRequest

    The URL request.

    file

    The file to upload.

    Return Value

    The created upload request.

  • Creates an upload request using the shared manager instance for the specified method, URL string, and data.

    Declaration

    Swift

    public func upload(
        method: Method,
        _ URLString: URLStringConvertible,
        headers: [String: String]? = nil,
        data: NSData)
        -> Request

    Parameters

    method

    The HTTP method.

    URLString

    The URL string.

    headers

    The HTTP headers. nil by default.

    data

    The data to upload.

    Return Value

    The created upload request.

  • Creates an upload request using the shared manager instance for the specified URL request and data.

    Declaration

    Swift

    public func upload(URLRequest: URLRequestConvertible, data: NSData) -> Request

    Parameters

    URLRequest

    The URL request.

    data

    The data to upload.

    Return Value

    The created upload request.

  • Creates an upload request using the shared manager instance for the specified method, URL string, and stream.

    Declaration

    Swift

    public func upload(
        method: Method,
        _ URLString: URLStringConvertible,
        headers: [String: String]? = nil,
        stream: NSInputStream)
        -> Request

    Parameters

    method

    The HTTP method.

    URLString

    The URL string.

    headers

    The HTTP headers. nil by default.

    stream

    The stream to upload.

    Return Value

    The created upload request.

  • Creates an upload request using the shared manager instance for the specified URL request and stream.

    Declaration

    Swift

    public func upload(URLRequest: URLRequestConvertible, stream: NSInputStream) -> Request

    Parameters

    URLRequest

    The URL request.

    stream

    The stream to upload.

    Return Value

    The created upload request.

  • Creates an upload request using the shared manager instance for the specified method and URL string.

    Declaration

    Swift

    public func upload(
        method: Method,
        _ URLString: URLStringConvertible,
        headers: [String: String]? = nil,
        multipartFormData: MultipartFormData -> Void,
        encodingMemoryThreshold: UInt64 = Manager.MultipartFormDataEncodingMemoryThreshold,
        encodingCompletion: (Manager.MultipartFormDataEncodingResult -> Void)?)

    Parameters

    method

    The HTTP method.

    URLString

    The URL string.

    headers

    The HTTP headers. nil by default.

    multipartFormData

    The closure used to append body parts to the MultipartFormData.

    encodingMemoryThreshold

    The encoding memory threshold in bytes. MultipartFormDataEncodingMemoryThreshold by default.

    encodingCompletion

    The closure called when the MultipartFormData encoding is complete.

  • Creates an upload request using the shared manager instance for the specified method and URL string.

    Declaration

    Swift

    public func upload(
        URLRequest: URLRequestConvertible,
        multipartFormData: MultipartFormData -> Void,
        encodingMemoryThreshold: UInt64 = Manager.MultipartFormDataEncodingMemoryThreshold,
        encodingCompletion: (Manager.MultipartFormDataEncodingResult -> Void)?)

    Parameters

    URLRequest

    The URL request.

    multipartFormData

    The closure used to append body parts to the MultipartFormData.

    encodingMemoryThreshold

    The encoding memory threshold in bytes. MultipartFormDataEncodingMemoryThreshold by default.

    encodingCompletion

    The closure called when the MultipartFormData encoding is complete.

  • Creates a download request using the shared manager instance for the specified method and URL string.

    Declaration

    Swift

    public func download(
        method: Method,
        _ URLString: URLStringConvertible,
        parameters: [String: AnyObject]? = nil,
        encoding: ParameterEncoding = .URL,
        headers: [String: String]? = nil,
        destination: Request.DownloadFileDestination)
        -> Request

    Parameters

    method

    The HTTP method.

    URLString

    The URL string.

    parameters

    The parameters. nil by default.

    encoding

    The parameter encoding. .URL by default.

    headers

    The HTTP headers. nil by default.

    destination

    The closure used to determine the destination of the downloaded file.

    Return Value

    The created download request.

  • Creates a download request using the shared manager instance for the specified URL request.

    Declaration

    Swift

    public func download(URLRequest: URLRequestConvertible, destination: Request.DownloadFileDestination) -> Request

    Parameters

    URLRequest

    The URL request.

    destination

    The closure used to determine the destination of the downloaded file.

    Return Value

    The created download request.

  • Creates a request using the shared manager instance for downloading from the resume data produced from a previous request cancellation.

    Declaration

    Swift

    public func download(resumeData data: NSData, destination: Request.DownloadFileDestination) -> Request

    Parameters

    resumeData

    The resume data. This is an opaque data blob produced by NSURLSessionDownloadTask when a task is cancelled. See NSURLSession -downloadTaskWithResumeData: for additional information.

    destination

    The closure used to determine the destination of the downloaded file.

    Return Value

    The created download request.

  • Returns whether the two network reachability status values are equal.

    Declaration

    Swift

    public func ==(
        lhs: NetworkReachabilityManager.NetworkReachabilityStatus,
        rhs: NetworkReachabilityManager.NetworkReachabilityStatus)
        -> Bool

    Parameters

    lhs

    The left-hand side value to compare.

    rhs

    The right-hand side value to compare.

    Return Value

    true if the two values are equal, false otherwise.