从Apple文档中了解到,每个应用程序都有一个沙箱,因此该应用程序的本地存储可以在其中存储数据和文件,而其他应用程序无法访问其数据和文件,但是我尝试创建文件通过应用程序并从中检索文件URL,然后创建另一个应用程序并将文件URL传递给它,但是新应用程序成功打开了该文件,为什么会发生这种情况?其他应用程序一定不能根据Apple文档打开文件
在第一个应用中: 我使用Alamofire下载文件
let destination: DownloadRequest.DownloadFileDestination =
{
(temporaryURL, response)in
let documentsPath = NSSearchPathForDirectoriesInDomains(.documentDirectory,.userDomainMask, true)[0]
let documentsURL = URL(fileURLWithPath: documentsPath, isDirectory: true)
let tmpURL = documentsURL.appendingPathComponent("wordFile.docx")
return (tmpURL, [.removePreviousFile, .createIntermediateDirectories])
}
Alamofire.download(urlString, to:
destination).responseData { response in
(response.destinationURL?.path)!
//The "response.destinationURL?.path" is: "/Users/user/Library/Developer/CoreSimulator/Devices/A0427AC0-6D5E-4734-A550-73A8224BD54D/data/Containers/Data/Application/4126243E-E166-4311-A950-D8FF49A07991/Documents/wordFile.docx"
})
在第二个应用中:
我从以前的应用程序(response.destinationURL?.path)!
获取了文件路径
并将其传递给webView,但webView显示文件成功