使用AlamoFire会话管理器下载调用时参数标签不正确

时间:2017-06-21 23:28:28

标签: ios xcode swift3 alamofire

AlamoFire的文档:

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])
}

我的代码:

    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

编译错误: enter image description here

1 个答案:

答案 0 :(得分:0)

您所要做的就是更新方法。您可以尝试自动填充但不可靠。我的猜测方法是这个方法(默认为GET):

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