small medium large xlarge

Back to: All Forums  Core Data
Generic-user-small
14 Nov 2011, 21:22
Erik Meißner (2 posts)

I tried to transfer the example from chapter 9 to a document based application. My setup starts from the “Cocoa Application” template with “Use Core Data” and “Create Document-Based Application” checked.

The application contains a very simple MOM and imports a larger dataset. The import updates in the UI via bindings. Everything is fine, but the UI is not responsive (and i did’t expect it would be responsive).

Now i create a NSOperation to perform the import in the background with its own MOC. And here it comes: Merging takes not place because an exception is thrown:

2011-11-14 22:12:59.950 CoreDataTest[21596:5d03] An uncaught exception was raised 2011-11-14 22:13:00.070 CoreDataTest[21596:5d03] This NSPersistentStoreCoordinator has no persistent stores. It cannot perform a save operation. [Switching to process 21596 thread 0x903] 2011-11-14 22:13:03.093 CoreDataTest[21596:5d03] *** Terminating app due to uncaught exception ‘NSInternalInconsistencyException’, reason: ‘This NSPersistentStoreCoordinator has no persistent stores. It cannot perform a save operation.’ terminate called after throwing an instance of ‘NSException’ warning: Attempting to create USE_BLOCK_IN_FRAME variable with block that isn’t in the frame.

I think that i have to add a persistent store to the coordinator, but i want to do it with the following constraints:

  • a new document has no file associated
  • a new document is not “dirty”
  • while importing data the UI is updated regularly via bindings
  • after importing data the document is dirty and has no file associated on disk
  • after clicking “Save…” the file chooser rises and the user can choose a filename and location
  • after saving the document to the new location the document is clean again

What do you think is the correct design pattern for this kind of application?

Avatarsmall_pragsmall
11 Dec 2011, 20:49
Marcus S. Zarra (284 posts)

If you are targeting Lion then I would suggest using a Parent/Child context configuration.

If you are targeting an older OS then I would suggest either:

A) Adding an in-memory store for the import and then copying to the on disk store after the import (messy) B) Saving to a temporary location and then changing the save routine to check if it is a temporary storage and then forcing a save-as

I prefer B.

You must be logged in to comment