Hi,

following the suggestions of "Efficiently Importing Data" in the Core Data Programming Guide, I use a second MOC (without an undo manager!) to import large amounts of data. While importing, this second MOC is saved and reset every x cycles to reduce memory usage. When done, it's saved again, everybody else gets notified about the new objects, the MOC is released and all is well.

My question now is how to implement undo for the whole import?

The first idea that comes to my mind looks something like this:
- implement a "removeManagedObjectsWithIDs:" somewhere (maybe category of NSManagedObjectContext?)
- after importing, make an array with IDs of the imported objects
- register an undo operation with the "main" MOC's undo manager that holds this method and the array

"removeManagedObjectsWithIDs:" would:
- group undo
- loop over the array
- remove the object
- ungroup undo

But I'm afraid, that approach won't scale well because of the looped deletion. I remember a previous post about the performance of deleting large amounts of managed objects...

Any suggestions regarding this? Any comments are highly appreciated!


Thanks,
Sebastian
_______________________________________________

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

Reply via email to