我正在嘗試將PDF文件下載到文檔目錄。請求成功,但請求完成後文件不存在於文檔目錄中。Alamofire不下載PDF文件
let destination = DownloadRequest.suggestedDownloadDestination(for: .documentDirectory)
let documentsDirectory = FileManager.SearchPathDirectory.documentDirectory
let userDomainMask = FileManager.SearchPathDomainMask.userDomainMask
let paths = NSSearchPathForDirectoriesInDomains(documentsDirectory, userDomainMask, true)
if paths.first != nil
{
Alamofire.download("http://www.test.com/pdfs/sample.pdf", to: destination).responseData
{ response in
if response.result.isFailure
{
print("\(response.error!)")
}
}
}
你怎麼知道它不是在文件目錄? – hasan83
@ hasan83我已經在Mac OSX Terminal的模擬器中檢查了應用程序的Documents目錄。 – Sicypher
@ bkhosh2可能會幫助你http://stackoverflow.com/q/41136560/6433023 –