如何在同一个iOS设备中将文件从一个应用程序传输到另一个应用程序?

问题描述:

我正在编写一个iOS应用程序,用于将同一设备上的另一个应用程序保存的文件转换为另一种格式。如何在同一设备中将文件从一个应用程序传输到另一个应用程序?请注意,文件是非文本文件。

I am writing an iOS application that performs conversion of a file saved by another application on the same device to another format. How can I transfer files from one application to another in the same device? Note that the files are non-textual files.

UIDocumentInteractionController

基本上它的工作原理如下:

Basically it works like this:


  1. 能够处理类型为XYZ的文件

  2. App 2实现 UIDocumentInteractionController ,并且将给用户选项将文件发送到App1 (我相信这必须是用户激活的)

  3. App 1 implements - (BOOL)application:openURL:sourceApplication:annotation:处理传输的文件,该文件将保存在您的 Documents / Inbox 目录中。从那里你可以复制文件在其他地方,然后处理它,确保你清理掉了保存在收件箱文件夹中的原始文件。

  1. App 1 registers as being able to handle files of type XYZ
  2. App 2 implements UIDocumentInteractionController and will give users the options to "send the file to App1" (I believe this has to be user activated)
  3. App 1 implements -(BOOL)application:openURL:sourceApplication:annotation: and deals with the transferred file which will be saved in your Documents/Inbox directory. From there you can copy the file elsewhere and then manipulated it, making sure you clean up by getting rid of the original one saved on the Inbox folder.

可供参考类别此处

可提供文档交互计划指南这里

Document interaction programming guide available here