你好,我正面临这个问题,我想通过resumeData发出alamofire请求,因此我编写了这段代码,但是我得到了这种错误类型的表达是模棱两可的,没有更多的上下文“。”
响应块,这就是我知道的,因为如果statemnt和。,则downloadRequest在其中。
当我拿出响应并将其设置为正常下载而没有恢复数据时,找不到响应,一切都很好,我该怎么办?
func StartDownload (with resumeData: Data? = nil) {
let fileUrl = self.getSaveFileUrl(fileName: Data[0] as String)
let destination: DownloadRequest.DownloadFileDestination = { _, _ in
return (fileUrl, [.removePreviousFile, .createIntermediateDirectories])
}
if let resumeData = resumeData {
downloadRequest = Alamofire.download(resumingWith: resumeData, to: destination)
} else {
downloadRequest = Alamofire.download(Data[0] as String , to:destination)
}
.downloadProgress { (progress) in
self.progressCircle.progress = progress.fractionCompleted
}
.response { defaultDownloadResponse in
if let error = defaultDownloadResponse.error {
print("someThing went wrong \(error)")
if let resumeDataa = defaultDownloadResponse.resumeData {
self.self.resumeData.updateValue(resumeDataa as NSData, forKey: self.Data[0])
}
return
}
if self.Data.count >= 2 {
self.Data.removeFirst()
self.startButton.isHidden = false
self.pauseButton.isHidden = true
self.resumeButton.isHidden = true
}
else if self.Data.isEmpty == true {
return
}
else {
self.Data.removeLast()
self.startButton.isHidden = true
self.pauseButton.isHidden = true
self.resumeButton.isHidden = true
}
self.progressCircle.progress = 0
self.progressLabel.text = "0%"
self.stateLabel.text = "Downloaded"
self.downloadTableView.reloadData()
self.SaveData()
}
}