Making a Request
1 | import Alamofire |
Response JSON Handler
1 | Alamofire.request("https://httpbin.org/get").responseJSON { response in |
Downloading Data to a File
Download data to a temporary file on-disk
1 | Alamofire.download("https://httpbin.org/image/png").responseData { response in |
Download File Destination
1 | let destination: DownloadRequest.DownloadFileDestination = { _, _ in |
Suggested download destination
1 | let destination = DownloadRequest.suggestedDownloadDestination(directory: .documentDirectory) |
Download Progress
1 | Alamofire.download("https://httpbin.org/image/png") |
Download Progress with dispatchQueue
1 | let utilityQueue = DispatchQueue.global(qos: .utility) |
Resuming a Download
1 | class ImageRequestor { |
Bug
Xcode的bug: 从cocoapods导入时,识别不了Alamofire。只要先Run一次,再import Alamofire就可以了