How can I transfer files from one application to another in the same iOS device?

后端 未结 2 1194
走了就别回头了
走了就别回头了 2020-12-07 23:29

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 appli

相关标签:
2条回答
  • 2020-12-08 00:12

    If you are developing both apps, you can store shared information in the keychain as long as your bundle identifiers conform to the same bundle seed id. See here for more info. Of course, if you are making both applications, you can use a URL scheme to pass in base64 encoded data as well.

    Update: As rog said below, UIDocumentInteractionController is great, but it is only available for 4.2 and up, so you are cutting out a major portion of your users if you want to use it.

    0 讨论(0)
  • 2020-12-08 00:26

    UIDocumentInteractionController is your friend.

    Basically it works like this:

    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.

    Class reference available here

    Document interaction programming guide available here

    0 讨论(0)
提交回复
热议问题