[英]Cannot convert value of type '(_, _, _) -> ()' to expected argument type 'Int64'
upload(urlRequest.1, with: urlRequest.0)
Progress {(bytesWritten, totalBytesWritten, totalBytesExpectedToWrite) in // Error Comes Here
print("\(Int64(totalBytesWritten)) / \(Int64(totalBytesExpectedToWrite))")
}
.responseJSON
{
response in
hideLoading()
showToast("Profile Updated Successfully!!")
}
The problem is that you've replaced .uploadProgress
with Progress
, but have not changed the three parameters to the closure to be the single Progress
parameter. 问题是您已经用
Progress
替换了.uploadProgress
,但是没有将闭包的三个参数更改为单个Progress
参数。
When you call .uploadProgress
, the first parameter to that closure is a Progress
(formerly known as NSProgress
). 调用
.uploadProgress
,该关闭的第一个参数是Progress
(以前称为NSProgress
)。 But the Alamofire method name, uploadProgress
, is unchanged. 但是Alamofire方法的名称
uploadProgress
保持不变。 Only the parameters to the closure have changed. 仅闭包的参数已更改。
Thus you want something like: 因此,您需要类似:
Alamofire.upload(data, with: request)
.uploadProgress { progress in
print(progress.fractionCompleted)
}
.responseJSON { response in
self.hideLoading()
switch response.result {
case .failure(let error):
self.showToast("Problem uploading: \(error.localizedDescription)")
case .success:
self.showToast("Profile Updated Successfully!!")
}
}
Bottom line, the upload progress method is called uploadProgress
, and it takes one parameter, a NSProgress
/ Progress
object. 最重要的是,上载进度方法称为
uploadProgress
,它采用一个参数,即NSProgress
/ Progress
对象。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.