Sharing a persistent store between iOS and Mac
Sharing a persistent store between iOS and Mac
- Subject: Sharing a persistent store between iOS and Mac
- From: Fritz Anderson <email@hidden>
- Date: Thu, 25 Aug 2011 15:30:10 -0500
iOS 4.3 Simulator, Xcode 4.1, Lion 10.7.1
I'm having trouble generating a Core Data store and opening it in an iOS app (in the Simulator so far).
My iOS app has to initialize a large, read-only dataset — a 12,000-word vocabulary with definitions. In my early drafts, with 6000 words, I had it parse a text file, but that took alarmingly long, and the watchdog timer would probably kill it if I attempted the full dictionary.
So if I'm initializing an SQLite Core Data store anyway, why not do so at build time, with a command-line tool on the Mac side?
So I have two targets. They share one managed-object class and a data model. The builds for both compile the data model into a .momd. It's not the same momd, but VersionInfo.plist in both is identical. The command-line tool takes the .momd and the vocabulary text, and produces vocab.sqlite in SRCROOT. Using Navicat for SQLite Lite, I verified that the contents of the file are (as far as I can tell) what I expect.
The iOS target copies vocab.sqlite as a resource. I verified (by eye and by an assertion in code) that it is in the .app bundle. I reviewed the build logs and verified that the .sqlite file came from the place to which the command-line tool wrote.
I get "The model used to open the store is incompatible with the one used to create the store" when the iOS app tries to add vocab.sqlite to the persistent store coordinator.
There is only one .momd in the .app bundle. The command-line tool takes a .momd as an argument; I've tried pointing it at the .momd inside the bundle; still "incompatible."
From everything I know to check, I'm doing this right. I've found nothing to suggest you can't put a Mac-generated store into an iOS app, and much to suggest that you should. I'm stymied. What should I try next?
— F
_______________________________________________
Cocoa-dev mailing list (email@hidden)
Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden