简体   繁体   中英

sharing core data datamodel between 2 iPhone apps


I'm new to coredata, so maybe one can tell me if what I plan makes sense or if there is another best practice to do it, so: Basically I am building 2 apps: one is getting data from various sources, puts them together and drops them into a core data datamodel. Since this takes its time I want this to run once in the simulator in a seperate app.

The other app is going to be shipped with that data ( and datamodel) So: two apps sharing the datamodel (and custom managedObject classes) and the sqlite file.

I don't want to rebuild the datamodel in the second app and keep the two in sync manually of course - so:

How do I do this ?
simply by adding the custom classes and .xcdatamodel file to the other project (without copying) and changing the filenames in the managedObjectModel and persistentStoreCoordinator Methods in the app Delegate to mach the file name of the datamodelfile from the first app?

sounds a bit odd to me...

thanks in advance.

If you are only sharing resources during development, in Xcode, then yes you will be able to share the same CD resources between Xcode projects. Just be sure that when you add the files to a new project that you uncheck the "copy items into destination group's folder", but beyond that it's not much tweaking to make it all work properly.

If you are talking about sharing CD resources during runtime on the iPhone, that isn't possible as @Björn stated in his answer.

每个应用程序都在自己的沙箱中运行,如果不在应用程序之间放置某种“中间人”以保持同步(例如Web服务器),则无法在应用程序之间共享数据。

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM