Functions
The following functions are available globally.
- 
                  
                  
Creates a
DataRequestusing the defaultSessionManagerto retrieve the contents of the specifiedurl,method,parameters,encodingandheaders.Declaration
Swift
@discardableResult public func requestWithCachPolicy( _ url: URLConvertible, method: HTTPMethod = .get, parameters: Parameters? = nil, encoding: ParameterEncoding = URLEncoding.default, headers: HTTPHeaders? = nil) -> DataRequestParameters
urlThe URL.
methodThe HTTP method.
.getby default.parametersThe parameters.
nilby default.encodingThe parameter encoding.
URLEncoding.defaultby default.headersThe HTTP headers.
nilby default.Return Value
The created
DataRequest. - 
                  
                  
Creates a
DataRequestusing the defaultSessionManagerto retrieve the contents of the specifiedurl,method,parameters,encodingandheaders.Declaration
Swift
@discardableResult public func request( _ url: URLConvertible, method: HTTPMethod = .get, parameters: Parameters? = nil, encoding: ParameterEncoding = URLEncoding.default, headers: HTTPHeaders? = nil) -> DataRequestParameters
urlThe URL.
methodThe HTTP method.
.getby default.parametersThe parameters.
nilby default.encodingThe parameter encoding.
URLEncoding.defaultby default.headersThe HTTP headers.
nilby default.Return Value
The created
DataRequest. - 
                  
                  
Creates a
DataRequestusing the defaultSessionManagerto retrieve the contents of a URL based on the specifiedurlRequest.Declaration
Swift
@discardableResult public func request(_ urlRequest: URLRequestConvertible) -> DataRequestParameters
urlRequestThe URL request
Return Value
The created
DataRequest. 
- 
                  
                  
Creates a
DownloadRequestusing the defaultSessionManagerto retrieve the contents of the specifiedurl,method,parameters,encoding,headersand save them to thedestination.If
destinationis not specified, the contents will remain in the temporary location determined by the underlying URL session.Declaration
Swift
@discardableResult public func download( _ url: URLConvertible, method: HTTPMethod = .get, parameters: Parameters? = nil, encoding: ParameterEncoding = URLEncoding.default, headers: HTTPHeaders? = nil, to destination: DownloadRequest.DownloadFileDestination? = nil) -> DownloadRequestParameters
urlThe URL.
methodThe HTTP method.
.getby default.parametersThe parameters.
nilby default.encodingThe parameter encoding.
URLEncoding.defaultby default.headersThe HTTP headers.
nilby default.destinationThe closure used to determine the destination of the downloaded file.
nilby default.Return Value
The created
DownloadRequest. - 
                  
                  
Creates a
DownloadRequestusing the defaultSessionManagerto retrieve the contents of a URL based on the specifiedurlRequestand save them to thedestination.If
destinationis not specified, the contents will remain in the temporary location determined by the underlying URL session.Declaration
Swift
@discardableResult public func download( _ urlRequest: URLRequestConvertible, to destination: DownloadRequest.DownloadFileDestination? = nil) -> DownloadRequestParameters
urlRequestThe URL request.
destinationThe closure used to determine the destination of the downloaded file.
nilby default.Return Value
The created
DownloadRequest. 
- 
                  
                  
Creates a
DownloadRequestusing the defaultSessionManagerfrom theresumeDataproduced from a previous request cancellation to retrieve the contents of the original request and save them to thedestination.If
destinationis not specified, the contents will remain in the temporary location determined by the underlying URL session.On the latest release of all the Apple platforms (iOS 10, macOS 10.12, tvOS 10, watchOS 3),
resumeDatais broken on background URL session configurations. There’s an underlying bug in theresumeDatageneration logic where the data is written incorrectly and will always fail to resume the download. For more information about the bug and possible workarounds, please refer to the following Stack Overflow post:Declaration
Swift
@discardableResult public func download( resumingWith resumeData: Data, to destination: DownloadRequest.DownloadFileDestination? = nil) -> DownloadRequestParameters
resumeDataThe resume data. This is an opaque data blob produced by
URLSessionDownloadTaskwhen a task is cancelled. SeeURLSession -downloadTask(withResumeData:)for additional information.destinationThe closure used to determine the destination of the downloaded file.
nilby default.Return Value
The created
DownloadRequest. 
- 
                  
                  
Creates an
UploadRequestusing the defaultSessionManagerfrom the specifiedurl,methodandheadersfor uploading thefile.Declaration
Swift
@discardableResult public func upload( _ fileURL: URL, to url: URLConvertible, method: HTTPMethod = .post, headers: HTTPHeaders? = nil) -> UploadRequestParameters
fileThe file to upload.
urlThe URL.
methodThe HTTP method.
.postby default.headersThe HTTP headers.
nilby default.Return Value
The created
UploadRequest. - 
                  
                  
Creates a
UploadRequestusing the defaultSessionManagerfrom the specifiedurlRequestfor uploading thefile.Declaration
Swift
@discardableResult public func upload(_ fileURL: URL, with urlRequest: URLRequestConvertible) -> UploadRequestParameters
fileThe file to upload.
urlRequestThe URL request.
Return Value
The created
UploadRequest. 
- 
                  
                  
Creates an
UploadRequestusing the defaultSessionManagerfrom the specifiedurl,methodandheadersfor uploading thedata.Declaration
Swift
@discardableResult public func upload( _ data: Data, to url: URLConvertible, method: HTTPMethod = .post, headers: HTTPHeaders? = nil) -> UploadRequestParameters
dataThe data to upload.
urlThe URL.
methodThe HTTP method.
.postby default.headersThe HTTP headers.
nilby default.Return Value
The created
UploadRequest. - 
                  
                  
Creates an
UploadRequestusing the defaultSessionManagerfrom the specifiedurlRequestfor uploading thedata.Declaration
Swift
@discardableResult public func upload(_ data: Data, with urlRequest: URLRequestConvertible) -> UploadRequestParameters
dataThe data to upload.
urlRequestThe URL request.
Return Value
The created
UploadRequest. 
- 
                  
                  
Creates an
UploadRequestusing the defaultSessionManagerfrom the specifiedurl,methodandheadersfor uploading thestream.Declaration
Swift
@discardableResult public func upload( _ stream: InputStream, to url: URLConvertible, method: HTTPMethod = .post, headers: HTTPHeaders? = nil) -> UploadRequestParameters
streamThe stream to upload.
urlThe URL.
methodThe HTTP method.
.postby default.headersThe HTTP headers.
nilby default.Return Value
The created
UploadRequest. - 
                  
                  
Creates an
UploadRequestusing the defaultSessionManagerfrom the specifiedurlRequestfor uploading thestream.Declaration
Swift
@discardableResult public func upload(_ stream: InputStream, with urlRequest: URLRequestConvertible) -> UploadRequestParameters
urlRequestThe URL request.
streamThe stream to upload.
Return Value
The created
UploadRequest. 
- 
                  
                  
Encodes
multipartFormDatausingencodingMemoryThresholdwith the defaultSessionManagerand callsencodingCompletionwith newUploadRequestusing theurl,methodandheaders.It is important to understand the memory implications of uploading
MultipartFormData. If the cummulative payload is small, encoding the data in-memory and directly uploading to a server is the by far the most efficient approach. However, if the payload is too large, encoding the data in-memory could cause your app to be terminated. Larger payloads must first be written to disk using input and output streams to keep the memory footprint low, then the data can be uploaded as a stream from the resulting file. Streaming from disk MUST be used for larger payloads such as video content.The
encodingMemoryThresholdparameter allows Alamofire to automatically determine whether to encode in-memory or stream from disk. If the content length of theMultipartFormDatais below theencodingMemoryThreshold, encoding takes place in-memory. If the content length exceeds the threshold, the data is streamed to disk during the encoding process. Then the result is uploaded as data or as a stream depending on which encoding technique was used.Declaration
Swift
public func upload( multipartFormData: @escaping (MultipartFormData) -> Void, usingThreshold encodingMemoryThreshold: UInt64 = SessionManager.multipartFormDataEncodingMemoryThreshold, to url: URLConvertible, method: HTTPMethod = .post, headers: HTTPHeaders? = nil, encodingCompletion: ((SessionManager.MultipartFormDataEncodingResult) -> Void)?)Parameters
multipartFormDataThe closure used to append body parts to the
MultipartFormData.encodingMemoryThresholdThe encoding memory threshold in bytes.
multipartFormDataEncodingMemoryThresholdby default.urlThe URL.
methodThe HTTP method.
.postby default.headersThe HTTP headers.
nilby default.encodingCompletionThe closure called when the
MultipartFormDataencoding is complete. - 
                  
                  
Encodes
multipartFormDatausingencodingMemoryThresholdand the defaultSessionManagerand callsencodingCompletionwith newUploadRequestusing theurlRequest.It is important to understand the memory implications of uploading
MultipartFormData. If the cummulative payload is small, encoding the data in-memory and directly uploading to a server is the by far the most efficient approach. However, if the payload is too large, encoding the data in-memory could cause your app to be terminated. Larger payloads must first be written to disk using input and output streams to keep the memory footprint low, then the data can be uploaded as a stream from the resulting file. Streaming from disk MUST be used for larger payloads such as video content.The
encodingMemoryThresholdparameter allows Alamofire to automatically determine whether to encode in-memory or stream from disk. If the content length of theMultipartFormDatais below theencodingMemoryThreshold, encoding takes place in-memory. If the content length exceeds the threshold, the data is streamed to disk during the encoding process. Then the result is uploaded as data or as a stream depending on which encoding technique was used.Declaration
Swift
public func upload( multipartFormData: @escaping (MultipartFormData) -> Void, usingThreshold encodingMemoryThreshold: UInt64 = SessionManager.multipartFormDataEncodingMemoryThreshold, with urlRequest: URLRequestConvertible, encodingCompletion: ((SessionManager.MultipartFormDataEncodingResult) -> Void)?)Parameters
multipartFormDataThe closure used to append body parts to the
MultipartFormData.encodingMemoryThresholdThe encoding memory threshold in bytes.
multipartFormDataEncodingMemoryThresholdby default.urlRequestThe URL request.
encodingCompletionThe closure called when the
MultipartFormDataencoding is complete. 
- 
                  
                  
Creates a
StreamRequestusing the defaultSessionManagerfor bidirectional streaming with thehostnameandport.If
startRequestsImmediatelyistrue, the request will haveresume()called before being returned.Declaration
Swift
@available(iOS 9.0, macOS 10.11, tvOS 9.0, *) @discardableResult public func stream(withHostName hostName: String, port: Int) -> StreamRequestParameters
hostNameThe hostname of the server to connect to.
portThe port of the server to connect to.
Return Value
The created
StreamRequest. 
- 
                  
                  
Creates a
StreamRequestusing the defaultSessionManagerfor bidirectional streaming with thenetService.If
startRequestsImmediatelyistrue, the request will haveresume()called before being returned.Declaration
Swift
@available(iOS 9.0, macOS 10.11, tvOS 9.0, *) @discardableResult public func stream(with netService: NetService) -> StreamRequestParameters
netServiceThe net service used to identify the endpoint.
Return Value
The created
StreamRequest. - 
                  
                  
Declaration
Swift
public func < (lhs: EKWeekday, rhs: EKWeekday) -> Bool - 
                  
                  
Declaration
Swift
public func == (lhs: EKWeekday, rhs: EKWeekday) -> Bool 
      Functions  Reference