RE: bindings and undo
RE: bindings and undo
- Subject: RE: bindings and undo
- From: Mark Onyschuk <email@hidden>
- Date: Fri, 16 Apr 2004 09:18:25 -0400
Can't see how there's any sort of problem with bindings and undo. As
per normal, put your undo code into your model and you'll find that
bindings automagically follow the execution of undo/redo as provided by
NSUndoManager.
The controller layer continues to use the same accessors that
pre-binding-layer code would have in past. Specifically, accessor
methods like this:
- (void)setFoo:(id)newFoo
{
if (![foo isEqual:newFoo]) {
[[self undoManagerWithTarget:self] setFoo:foo];
[foo release];
foo = [newFoo copyWithZone:[self zone]];
}
}
...so undos are registered in the same-old-same-old way even though now
they're triggered by bindings.
And because undo manager style redo's typically call through accessors
as well, and key-value-observing watches these sorts of things, your
interface will be updated in the same way it would if you simply called
[myObject setFoo:someNewFoo] by hand...
I've briefly scanned through the archives, and best I can tell,
complaints about undo have mostly to do with "transaction" support as
supplied by the old EOF "editing context" concept which allowed for
atomic (ie. undoable), grouped updates of object graphs. Outside of DB
applications, that's not really germane to most run-of-the-mill Cocoa
coding.
-Mark
_______________________________________________
cocoa-dev mailing list | email@hidden
Help/Unsubscribe/Archives:
http://www.lists.apple.com/mailman/listinfo/cocoa-dev
Do not post admin requests to the list. They will be ignored.