Synchronize Core Data with SQL or MySQL Via SQLite
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?
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.
精彩评论