Re: Help with Undo and MVC
Re: Help with Undo and MVC
- Subject: Re: Help with Undo and MVC
- From: Stephen Magyari <email@hidden>
- Date: Tue, 04 Nov 2003 18:01:43 -0800
Thanks; tried that, and it says, "'Book' may not respond to ' -undoManager'"
*sigh*
Would it help if I just put the project in a .sit file and posted it for
download so you could see the whole thing? Might be more apparent what I'm
doing wrong if everything's viewed "in context"....
--Stephen
on 11/3/03 10:16 PM, Laurent Daudelin at email@hidden wrote:
>
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.
_______________________________________________
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.