2017-06-21 74 views
1

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

+0

相關https://stackoverflow.com/questions/41136560/setting-alamofire-custom-destination-file-name-instead-of-使用-suggesteddownloa –

回答

0

所有你需要做的是更新的方法。您可以嘗試自動填充,但其不可靠的。我的猜測是該方法是這樣的方法(以獲得其默認值):

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

其在文檔中的Alamofire 4:https://github.com/Alamofire/Alamofire/blob/master/Documentation/Alamofire%204.0%20Migration%20Guide.md –

+0

這是解決方案? –