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 23:08:54 -0500
on 11/4/03 9:01 PM, Stephen Magyari at email@hidden wrote:
>
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.
>
Yes, might be easier to spot what is wrong.
-Laurent.
--
============================================================================
Laurent Daudelin AIM/iChat: LaurentDaudelin <
http://nemesys.dyndns.org>
Logiciels Nemesys Software
mailto:email@hidden
fat-finger vt.: 1. To introduce a typo while editing in such a way that the
resulting manglification of a configuration file does something useless,
damaging, or wildly unexpected. "NSI fat-fingered their DNS zone file and
took half the net down again." 2. More generally, any typo that produces
dramatically bad results.
_______________________________________________
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.