Type of expression is ambiguous without more context error in this code -> responseData{ (response) in

53 views Asked by At

i am using this code for download video and it will give me an error the code is given below

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
            }

enter image description here

1

There are 1 answers

0
son On

The response.result is Result<Data, AFError>, and it doesn't have the value property. You can do it this way:

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
}

Or

switch response.result {
case .success(let data):
    break
case .failure(let error):
    break
}