small medium large xlarge

Back to: All Forums  Core Data
22 Jul 2010, 12:40
Jonathan D Schmidt (4 posts)

I have purchased your book (excellent, by the way) and I’m still going through it. So far, I haven’t found a way to do what I need, though. Hopefully someone can point me in the right direction. I’m an experienced developer, but new to Mac. I just don’t want to go down one path only to find out that I made some fundamental error or incorrect assumption later on.

I want to ultimately build and sell an iPhone app using Core Data. Here is what I want to be able to do:

  1. Build a Mac OS X utility app that points to the same Core Data object model, but has its own “master” database.
  2. Populate the master database using the Mac app.
  3. Export a subset of the master data from the Mac app to a flat file (XML?) that is a subset of the master data.
  4. Import that data into the local iPhone data store.

Number 2 should be easy enough. I have read about the XML Parser that should help me with #4. I need help with #1 and 3.

For #1, I can’t figure out how I can maintain one object model for both apps with Xcode. That data model must accept model versioning. Do I just create two Projects, one Mac and one iPhone, and point them both to the same .xcdatamodel file and the magic happens for me?

For #3, is there any sample code that someone can share that will iterate through an array of objects to create the XML?

Any help is appreciated!


22 Jul 2010, 22:46
Greg Robertson (21 posts)

You can use the same CoreData database if you save it as *.sqlite. Simply build you master, write a small function to move the data from one data store to another and then use the small sqlite data source when you build your iPhone app as a resource and set your coredata data store to it when the app initiates.

Pretty simple once you get used to core data. The main diff is to build the sub-set you have to iterate through each record individually to save to a new data source since there is no SQL function to build a sub-set db.

Hope this helps.

You are on the right track choosing CoreData, it is great once you get used to it.

If you are just starting out I suggest trying mogenerator (it’s free):


22 Jul 2010, 22:48
Greg Robertson (21 posts)

Actually this link might be better:

01 Aug 2010, 20:41
Jonathan D Schmidt (4 posts)

Thanks for the help! I’ll give that a try!

You must be logged in to comment