【发布时间】:2015-03-28 22:14:23
【问题描述】:
我正在尝试下载文件并将其保存到 Documents 目录。我已经在客户端本地完成了这个,没有问题,但是当我在 Alamofire 中使用相同的路径时,我得到了一系列错误。
这是下载组件:
func downloadFileAtIndex(index: Int) {
Alamofire.download(.GET, "\(serverURL)/user/\(userID)/project/\(arrayOfProjectIDs[index])/deliverable", { (temporaryURL, response) in
let destinationFolder: String = NSSearchPathForDirectoriesInDomains(.DocumentDirectory, .UserDomainMask, true)[0] as String
let filePath: NSURL = NSURL.fileURLWithPath("\(destinationFolder)/\(arrayOfProjectIDs[index])/myFile.png")!
return filePath
})
}
回复是:The operation couldn’t be completed. (Cocoa error 4.)
错误是:The operation couldn’t be completed. No such file or directory.
我知道该目录还不存在,但我想创建它,在本地保存时这似乎不是问题。任何见解将不胜感激。
【问题讨论】: