我有这种代码
systemctl restart openstack-nova-*
systemctl restart openstack-nova-scheduler.service
结果不能给我带来任何进步。它只返回let req = Alamofire.request(url, method: .post, parameters: parameters, encoding: JSONEncoding.default, headers: headers)
req.downloadProgress { (progress) in
print("progess!", Float(req.progress.fractionCompleted))
}
req.responseJSON { response in
if response.result.isSuccess {
print(response.result.value!)
}
else {
print(response.result.error!)
}
}
,就这样,但是我需要此请求的进度。
请有人帮助我。
答案 0 :(得分:1)
使用req.progress.fractionCompleted
时出错。改用progress.fractionCompleted
。
let req = Alamofire.request(url, method: .post, parameters: parameters, encoding: JSONEncoding.default, headers: headers)
req.downloadProgress { (progress) in
print("progess!", Float(progress.fractionCompleted))
}
req.responseJSON { response in
if response.result.isSuccess {
print(response.result.value!)
}
else {
print(response.result.error!)
}
}
答案 1 :(得分:0)
在主队列中添加进度
request?.downloadProgress(queue: .main,closure: {progress in
self.downloadProcess.text = "Download \((progress.fractionCompleted*100))% completed"
print(self.downloadProcess.text)
if #available(iOS 11.0, *) {
} else {
// Fallback on earlier versions
}
})