Core Data and undo action names
Core Data and undo action names
- Subject: Core Data and undo action names
- From: Bill Cheeseman <email@hidden>
- Date: Mon, 22 Aug 2005 07:21:53 -0400
I have just completed the task of implementing meaningful undo action names
in my Core Data application. For the most part it was strightforward. I just
invoke -setActionName: in each setter or other method that changes a Core
Data value.
But one situation was hard, and I wonder if there is a simple way to
generalize it.
Some operations not only change a value directly but also trigger secondary
changes. In such a case, the undo action name should describe the initiating
operation, not the secondary changes, and undoing it will automatically
reverse all the secondary changes. But if the secondary changes are
accomplished through setters that invoke -setActionName: (because sometimes
these setters are invoked directly as an initiating operation), the
initiating operation's undo action name gets replaced by the secondary
change's undo action name. Whichever secondary change happens last wins.
In some cases, I have overcome this by disabling undo registration in the
observer and, in the secondary setter, testing whether undo registration is
enabled. That's pretty easy. But in other cases the observer is Cocoa
bindings and I don't have immediate access. As a result, I have to think
through the logic for each secondary setter independently and devise a
special test before invoking -setActionName:. That is very hard,
time-consuming, and error-prone.
Is there a better way?
--
Bill Cheeseman - email@hidden
Quechee Software, Quechee, Vermont, USA
http://www.quecheesoftware.com
PreFab Software - http://www.prefab.com/scripting.html
The AppleScript Sourcebook - http://www.AppleScriptSourcebook.com
Vermont Recipes - http://www.stepwise.com/Articles/VermontRecipes
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Cocoa-dev mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden