views:

641

answers:

1

I am trying to build an iPhone application using core data's built in table management. I want synchronize the data with an MSSQL or MySQL database. Core data is compatible with SQLite so I thought it might work as a bridge. Can anyone think of how one might achieve this functionality?

+4  A: 

You are thinking about this wrong. CoreData is not "compatible" with SQLite. One of its backing store types using SQLite as an implementation detail. The actual content of that SQLite DB is undocumented and internal to CoreData. This is a key point, you can't use an arbitrary SQLite3 DB with CoreData, CoreData makes a SQLite3 DB for a particular model.

If you want to synch data from another DB in CoreData you need to query that DB, get the response data, then create and update NSManagedObjects based on that data. The exact details of how you do that (through a webservice and app server wrapping your DB, with a DB client library embedded in your app, etc) will depend on the exact nature of the server and how you want to interact with it, but you won't be synching around SQL tables under CoreData and having CD magically work by describing the table layout to it, the updates need to go through the standard CoreData interfaces just like any other object manipulation.

Louis Gerbarg
Interesting. So would you use soap, rest, json or ?
Bryan
Personally I tend to use JSON served via REST interface for this sort of thing because it tends to take less bandwidth than SOAP, but what is best will really depend on your exact situation.
Louis Gerbarg
Thanks Louis--!
Bryan