Undo with table view and array controller
Undo with table view and array controller
- Subject: Undo with table view and array controller
- From: Ulrich Hobelmann <email@hidden>
- Date: Mon, 18 Dec 2006 17:55:06 +0100
Finally found some time for Cocoa again.
I'm just implementing undo for my tableview which is linked to an
arraycontroller. I'm registered for KVO changes.
Problem: when the user removes a batch of entries, I do get the removed
indexes, as well as an array of objects that were removed. I do a
prepareWithInvocation... on the undomanager, then call
insertObjects:atIndexes: which has the problem that the array minus the
removed objects does not have those indexes anymore.
So how is this traditionally done? How do people calculate where
values should be added, especially in a code-free setting (i.e. when
bindings and the like are extensively used)?
Undoing an addObjects: is also problematic, because the undo removes
the objects, but doesn't signal a change to the tableview (even though
the TV is *bound* to the array). Is there a way to get this
automatically, or do I have to write my own undo-method that will both
remove the objects and tell the TV about it?
And concerning NSKeyValueChangeReplacement: what's that all about? How
can you replace values, as the user? Does this ever happen? If so, is
this basically just a ChangeSetting on multiple values (and should be
handled accordingly)?
Finally a meta-question: does not undo lead to huge memory leaks?
After all, you keep all changes the user ever made in memory, i.e. both
the document and all diffs. This is like instead of having a file in
memory, you keep its whole SVN history, and that for every document in
every application. Do most apps just discard all undos when the user
calls save: (which I find is bad practise; I like undoing beyond the
save:)?
Best regards,
Ulrich
_______________________________________________
Cocoa-dev mailing list (email@hidden)
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