> > > I'll probably end up using the "merge..." method available but that makes > me feel bad to save a document automatically when the user should be the > only one responsible for this. For example, the user will not be able to use > the "Revert" command from the File menu to restore his document to its > original state like it is supposed to work (or I'll probably have to > subclass the standard behavior by saving a copy of the sqlite file in the > temp area just in case the user needs to revert). > > Eric._______________________________________________
I'm not a Core Data expert by any stretch of the imagination, but NSPersistentDocument does support revert and other such features, so it's clearly possible. The NSPersistentDocumentation Class Reference<http://developer.apple.com/mac/library/documentation/cocoa/Reference/ApplicationKit/Classes/NSPersistentDocument_Class/Reference/Reference.html> indicates that the "save" operation simply adds a new persistent store (if it is not already saved) to the managed object context and then invokes save:. This suggests a possible solution: When the user opens your application, use an in-memory "persistent" store. If they're opening an existing document, use the migrate... method on NSPersistentStoreCoordinator to migrate the on-disk store to an in-memory one. Once you've loaded everything into memory, you can invoke "save" on multiple MOCs as much as you like without it being written to disk, since the on-disk store is no longer attached. When you actually want to save to disk, simply add an on-disk persistent store to the MOC. You'd probably just delete the old on-disk one and then add a new persistent store at the same URL. I assume you'd have to call "save" on your MOC after doing so. You could then immediately remove the on-disk store and continue on with in-memory store. Alternatively, you could migrate to an on-disk store and then back to an in-memory store, but I suspect that would be less efficient. I've tried precisely none of the above personally. I'm just throwing ideas out there. If the above isn't a feasible way to do this in Core Data, I'd love to know why. -BJ Homer _______________________________________________ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) 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: http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to arch...@mail-archive.com