Question

Is it possible to share a core data store between two different iPhone apps signed by the same developer? I would like to develop an application where one iPhone app will save a stream of data, which can then be read by the other app. Is this even possible? Thanks a lot!

Was it helpful?

Solution

No, that's not possible. An iPhone application runs in a sandbox and though doesn't have access to another applications data store.

Edit:

After reading the others answers here: Yes, Custom URLs are possible. And yes it's possible to transfer data with it, but, I, in my opinion, wouldn't recommend this procedure to transfer more than 5kb of data. There is no failsafe: No transactions and no relations.

OTHER TIPS

Now in iOS 5 with iCloud you can register both apps with the same iCloud URL. On initialization of the second app, the core data store of the first is more/less copied into the second. This can take while---so you need to start the persistent store controller in a background thread, or you app will be killed by a watchdog timer.

However, there are a few caveats.

  • It doesn't seem to work completely correctly. Some records form the core data database do not seem to be copied. In my experience it seems random which records do not make it. Maybe it is related to to consistency of the original store.

  • afterwards, the tho apps do not seem to stay in sync, contrary to the same app on two different iDevices.

Debugging is a bit of a pain, as it takes 10--20 seconds before a change from one iDevice is transferred to another, and apparently indefinitely before a change from one app on the same iDevice makes it to another app registered with the same iCloud URL.

So in summary---you can copy most records using iCloud on init of the second app, but it is hard to keep them in sync.

This can be done using a custom url scheme on the iphone, with some caveats.

If you use a custom url scheme, only one app "owns" the data. The other app would have to import data from the main app... Mobile Orchard did an article on this for moving data from a lite app to a paid for app

http://www.mobileorchard.com/lite-to-paid-iphone-application-data-migrations-with-custom-url-handlers/

But I recently came across an MIT licensed library called "SwapKit" that may do exactly what you want as well... Sounds good from the overview on their site, though I haven't tried it:

http://infinite-labs.net/swapkit/

and this may or may not be of any help, but check out "SpyPhone" too:

SpyPhone shows the kind of data a rogue application can collect in a non jailbroken iPhone.

http://github.com/nst/SpyPhone

You could use a custom URL scheme to send the data to the second App.

-t

There's also the system pasteboard (I think it's NSPasteboard or something, no time to check right now) which is basically the clipboard. I think you can put stuff on it and then launch another app with a URL that tells the other app to check the pasteboard.

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