views:

42

answers:

2

Hi all,

I'm working on an app that uses Core Data, and I'd like to be able to code it in a way that it can use a local SQLite store or a web-based store (with an XML or JSON response schema).

Is it possible to use the exact same code for the Core Data stuff and just select the appropriate persistence store based on a user's preference?

+1  A: 

You can connect to a remote store via a URL but that doesn't sound like what you want as that would support only one store for every remote user.

Really, all you need to do is setup a regular SQLite store and then add a little code to send changes to the server via the chosen method. Then you could turn the server connection on and off as needed.

That would be simplest as long as you don't have a requirement that no data be persisted on the device itself.

TechZen
Even if there was a requirement of no data persisted on the device, an In-Memory story could be used but the bandwidth requirements would be higher since the entire store would need to be pulled down on each launch.
Marcus S. Zarra
+3  A: 

Look at the WWDC video "Building a server-driven user experience".

Amorya
nice, didn't know about them until your answer. http://developer.apple.com/videos/wwdc/2010/
Henry