我正在使用Alamofire下载一个文件并且进度下载,但我不知道如何暂停/恢复/取消特定请求。如何在Alamofire中暂停/恢复/取消我的下载请求
@IBAction func downloadBtnTapped() {
Alamofire.download(.GET, "http://httpbin.org/stream/100", destination: destination)
.progress { (bytesRead, totalBytesRead, totalBytesExpectedToRead) in
println(totalBytesRead)
}
.response { (request, response, _, error) in
println(response)
}
}
@IBAction func pauseBtnTapped(sender : UIButton) {
// i would like to pause/cancel my download request here
}
这是否取消所有请求? – 2015-07-16 09:54:30
'request.cancel()'不保证立即取消请求。这使取消后调用进度块。有没有任何内置的方法来检查取消/挂起是否被调用? – osrl 2016-04-27 10:35:52
暂停是请求?.suspend()或请求?取消()? – Steve 2016-06-27 06:47:00