我正在使用此代码下载视频,它会给我一个错误,代码如下
let videoImageUrl = "my_video_link"
AF.request(videoImageUrl).downloadProgress(closure: { (progress) in
// print(progress.fractionCompleted)
}).responseData { (response) in
// }
if let data = response.result.value {
// my code
}
response.result
是 Result<Data, AFError>
,并且它没有 value
属性。你可以这样做:
if let data = try? response.result.get() {
//TODO: do something with data
}
do {
let data = try response.result.get()
//TODO: do something with data
} catch {
//Catch error here
}
或者
switch response.result {
case .success(let data):
break
case .failure(let error):
break
}