如何在iOS中编辑和保存存储在本地目录中的Microsoft Word文档?

Sid*_*tre 6 dropbox ios swift swift3

我正在使用 Dropbox 和 Microsoft word。我可以从 Dropbox 下载文件并存储在本地存储中(在 Document 目录中)。现在我想编辑word文档。我尝试了几种方法,但对我不起作用。

下载到本地存储并使用 Microsoft Word 打开,UIDocumentInteractionController但其打开时只读复制并保存在 Microsoft Word 应用程序中:

let file = URL(fileURLWithPath: dirPath).appendingPathComponent("/\(filename)")
// Do whatever you want with the document
self.docController = UIDocumentInteractionController(url: file)
self.docController.delegate = self
self.docController.presentOpenInMenu(from: self.view.frame, in: self.view, animated: true)
Run Code Online (Sandbox Code Playgroud)

在本地存储中下载并使用 Microsoft Word 应用程序的 URL 方案使用 Microsoft Word 打开,但失败并显示错误无法打开文件:

let url : NSString = "ms-word:ofe|u|\(directoryContents[0])|z|yes|a|App" as NSString
let urlStr : NSString = url.addingPercentEscapes(using: String.Encoding.utf8.rawValue)! as NSString
let searchURL : NSURL = NSURL(string: urlStr as String)!
UIApplication.shared.openURL(searchURL as URL)
Run Code Online (Sandbox Code Playgroud)

在此处输入图片说明

使用 Microsoft Word 应用程序的 URL 方案在 Word 应用程序中直接下载文件(使用 Dropbox 共享链接),但失败并显示错误无法打开文件:

let url : NSString = "ms-word:ofv|u|https://www.dropbox.com/s/xxxxxx/new.docx?dl=0|p|xxxxxx|z|yes|a|App" as NSString
let urlStr : NSString = url.addingPercentEscapes(using: String.Encoding.utf8.rawValue)! as NSString
let searchURL : NSURL = NSURL(string: urlStr as String)!
UIApplication.shared.openURL(searchURL as URL) 
Run Code Online (Sandbox Code Playgroud)

在此处输入图片说明 在此处输入图片说明

我知道这是因为 iOS 沙盒。不允许跨应用程序共享数据。我不想使用 Dropbox 应用来编辑和更新文件?

有没有办法从 Dropbox 下载 word 文件并在应用程序内编辑或使用 Microsoft word 应用程序?