Question

Is there a temporary directory that all applications have access to in iOS so that files can be passed between them?

Please Note: I understand the "Open In" menu of UIDocumentInteractionController. I'm hoping to pass a file by calling openURL on UIApplication instead. I'm trying NOT to use the "Open In" menu.

Was it helpful?

Solution 2

As "Martin R" pointed out, there is no common directory anywhere that you can use for this purpose.

Since you have control over both apps, you do have a solution that will allow the two apps to share files and/or data. This will require that both apps be updated to support this feature.

The solution involves the use of UIPasteBoard. You can either use the general pasteboard or you can use a "private" named pasteboard. If you use a named pasteboard, both apps need to agree on the name (or the name can be passed as part of the URL when you call openURL:).

Have the source app call setData:forPasteBoardType: on the (named or general) pasteboard. Then the source app should create a URL to the other app. The URL should include a couple of query parameters that include the name of the pasteboard (if appropriate) as well as the pasteboard type used to set the data.

When the receiving app is launched, it gets the query parameters and uses those to get the pasteboard and then the data with the proper type.

This solution may have issues if the file you need to pass gets to be too big. I've used this with multi-megabyte files. Since the data is being loaded in memory, the amount of data must have an upper limit. Please test properly on real devices with the largest files you expect to transfer.

OTHER TIPS

No there isn't. The only shared location (in some sense) is the Photo Library, which each application can use to load and save images (if the user permits it). Apart from that, each application has only access to its own Documents, Library etc. folders.

(Of course I am not speaking about jailbroken devices.)

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top