Re: Help with Undo and MVC
Re: Help with Undo and MVC
- Subject: Re: Help with Undo and MVC
- From: Laurent Daudelin <email@hidden>
- Date: Tue, 04 Nov 2003 01:16:43 -0500
on 11/3/03 11:24 PM, Stephen Magyari at email@hidden wrote:
>
Thank you to Laurent and Drew for the responses, which helped me clarify my
>
question --
>
>
How do I get my model to know that an NSUndoManager exists in my document?
>
I think I need to either pass the undo manager "down" to the model or have
>
the model keep a pointer "up" to the document, but I'm lost in either case
>
in that I can't figure out exactly how to do it in a way that works.
>
>
Currently I have in my document's header:
>
- (NSUndoManager *)undoManager;
>
>
and in the implementation:
>
>
- (NSUndoManager *)undoManager {
>
return [self undoManager];
>
}
>
>
Is that correct? If not, how should I do it? If it is correct, then what
>
should I do differently in the set method below (from my model's
>
implementation) to get it to recognize "undoManager" (which Xcode says is
>
undeclared)?
>
>
- (void)setBookTitle:(NSString *)title;
>
{
>
[[undoManager prepareWithInvocationTarget:self]
>
setBookTitle:newBookTitle];
>
[newBookTitle release];
>
newBookTitle = title;
>
}
>
>
I've tried Drew's suggestion:
>
[[[doc undoManager] prepareWithInvocationTarget:self]];
>
>
But then Xcode says "doc" is undeclared, etc...
>
>
I'm clearly missing something or am doing something wrong and need a nudge
>
(violent shove?) in the right direction. Thank you for the assistance thus
>
far...
Which class is implementing the undoManager method? Your document class? If
so, then you should replace the 'doc' in the above method with 'self',
unless I miss something. That would be:
[[self undoManager] prepareWithInvocationTarget:self];
-Laurent.
--
============================================================================
Laurent Daudelin AIM/iChat: LaurentDaudelin <
http://nemesys.dyndns.org>
Logiciels Nemesys Software
mailto:email@hidden
fish n.: [Adelaide University, Australia] 1. Another metasyntactic variable.
See foo. Derived originally from the Monty Python skit in the middle of "The
Meaning of Life" entitled "Find the Fish". 2. A pun for `microfiche'. A
microfiche file cabinet may be referred to as a `fish tank'.
_______________________________________________
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.