Incorrect argument label in call wtih AlamoFire Session Manager download

落花浮王杯 提交于 2019-12-11 08:17:01

问题


AlamoFire's documentation:

let destination: DownloadRequest.DownloadFileDestination = { _, _ in
    let documentsURL = FileManager.default.urls(for: .documentDirectory, in: .userDomainMask)[0]
    let fileURL = documentsURL.appendingPathComponent("pig.png")

    return (fileURL, [.removePreviousFile, .createIntermediateDirectories])
}

My code:

    fileprivate let manager: Alamofire.SessionManager = { ... 

    let destination: DownloadRequest.DownloadFileDestination = { _, _ in
        let documentsURL = FileManager.default.urls(for: .documentDirectory, in: .userDomainMask)[0]
        let fileURL = documentsURL.appendingPathComponent(".mp4")
        return (fileURL, [.removePreviousFile, .createIntermediateDirectories])
    }

...

        self.manager.download(urlString, to: destination) { response in

compile error:


回答1:


All you have to do is update the method. You can try to autofill but its unreliable. My guess is the method is this method (which defaults to GET):

self.manager.download(urlString, to: destination).response { 
    (response) in 
    print(response)
}


来源:https://stackoverflow.com/questions/44687745/incorrect-argument-label-in-call-wtih-alamofire-session-manager-download

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!