Undo and two NSManagedObjectContexts
Undo and two NSManagedObjectContexts
- Subject: Undo and two NSManagedObjectContexts
- From: Sebastian Morsch <email@hidden>
- Date: Thu, 08 Oct 2009 14:11:50 +0200
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 (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