Re: UndoManager
Re: UndoManager
- Subject: Re: UndoManager
- From: Olivier <email@hidden>
- Date: Fri, 15 Nov 2002 08:54:51 -0600
On Thursday, November 14, 2002, at 05:45 AM, Craig Bakalian wrote:
Hi,
Still coding away at my music notation app. I was just about finished
the Data Model Classes when bam!, I realized I need redo and undo in
the app. I went for a walk through the SKTDrawDocument in the
Sketch.app. I think I understand how to register the selector and
object with the NSUndoManager, yet in the Sketch.app I see this-
- (void)insertGraphic:(SKTGraphic *)graphic atIndex:(unsigned)index {
[[[self undoManager] prepareWithInvocationTarget:self]
removeGraphicAtIndex:index];
[_graphics insertObject:graphic atIndex:index];
[graphic setDocument:self];
[self invalidateGraphic:graphic];
}
This brings up many questions in my average IQ type head, firstly I
can't find the instance or function definition of undoManager that
[self undoManager] , so is this an inherited method? I am assuming that
[self undoManager] is a getter. I mean, it has to be. So, were is the
get, in NSDocument?
Yes, undoManager is a method of the NSDocument class.
Also, I am trying to make the distinction between [[undoMangager
prepareWithInvocationTarget: self] someMethod: ], and [undoManager
registerUndoWithTarget: self selector:@selector( ) object: ]; Both
of these methods need to register the state that the object was in
before the edit, cut, copy, or paste occured, right? So, what is the
difference?
One allow to pass an unlimited number of parameter where the other one
limit yourself to one parameter.
The above code really shows what is going on, because the
insertGraphics definition registers the undoManager to
removeGraphicsAtIndex.
look at this file on your hard drive:
file://localhost/Developer/Documentation/Cocoa/TasksAndConcepts/
ProgrammingTopics/UndoArchitecture/Tasks/RegisteringUndo.html#BABICFDE
Craig Bakalian
_______________________________________________
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.
_______________________________________________
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.
References: | |
| >UndoManager (From: Craig Bakalian <email@hidden>) |