表达式类型不明确,此代码中没有更多上下文错误 ->responseData{(响应)in

问题描述 投票:0回答:1

我正在使用此代码下载视频,它会给我一个错误,代码如下

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
            }

swift alamofire alamofire-request
1个回答
0
投票

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
}
© www.soinside.com 2019 - 2024. All rights reserved.