0
func downloadProgress(bytesRead: Int64, totalBytesRead: Int64,
totalBytesExpectedToRead: Int64) {
let percent = Float(totalBytesRead)/Float(totalBytesExpectedToRead)
dispatch_async(dispatch_get_main_queue(), {
self.progress.setProgress(percent,animated:true)
})
print("Progress:\(percent*100)%")
}
func downloadResponse(request: NSURLRequest?, response: NSHTTPURLResponse?,
data: NSData?, error:NSError?) {
if let error = error {
if error.code == NSURLErrorCancelled {
self.cancelledData = data
} else {
print("Failed to download file: \(response) \(error)")
}
} else {
print("Successfully downloaded file: \(response)")
}
}
@IBAction func continueBtnClick(sender: AnyObject) {
if let cancelledData = self.cancelledData {
self.downloadRequest = Alamofire.download(resumeData: cancelledData,
destination: destination)
self.downloadRequest.progress(downloadProgress)
self.downloadRequest.response(completionHandler: downloadResponse)
self.stopBtn.enabled = true
self.continueBtn.enabled = false
}
}
Alamofire 3.1ではコードが正常に機能しますが、Swift 3.0およびAlamofire 4.0にアップグレードした後は機能しません。4.0へのアップグレード後にAlamofireメソッドが機能しない
次の2本のラインは、 "そのような進歩FO memeber" と
- self.downloadRequest.progress(downloadProgress)
- self.downloadRequest.response(completionHandler "応答のそのような部材" エラーを示しません。ダウンロード応答)
どのようにこれらの2つの問題を解決できますか?
ありがとうございました。
ありがとうございます。できます。 – jdleung
@jdleung恐ろしい!私は助けることができてうれしいです – tech4242