我尝试在下载后使用 Alamofire 下载.pdf
文件。但我见过只使用过" webview"。因此,应用程序消耗大量内存并且不可行。
我想要的是使用本机设备应用程序打开它。有什么建议?谢谢。
编辑:这是我的下载文件代码:
var localPath: NSURL?
Alamofire.download(.GET, url, destination: { (temporaryURL, response) in
let directoryURL = NSFileManager.defaultManager().URLsForDirectory(.DocumentDirectory, inDomains: .UserDomainMask)[0]
let pathComponent = response.suggestedFilename
localPath = directoryURL.URLByAppendingPathComponent(pathComponent!)
return localPath!
})
.response { (request, response, _, error) in
if error != nil
{
// got an error in getting the data, need to handle it
print("Error: \(error!)")
}
//print(response)
print("Download file en:\(localPath!)")
self.view.hideToastActivity()
//self.actioncall()
}
}
我需要从localpath打开文件......