Re: A niceMessage in MyDocument
Re: A niceMessage in MyDocument
- Subject: Re: A niceMessage in MyDocument
- From: Carlos Weber <email@hidden>
- Date: Tue, 19 Jun 2001 16:06:42 -1000
On Tuesday, June 19, 2001, at 01:19 PM, Joshua D. Orr wrote:
>
Does your "MyWindowController.m" import the header file
>
"MyDocument.h"? It
>
can't find the method, that is it's first complaint. Always take the
>
first
>
complaint more seriously, because fixing the first one sometimes can fix
>
other complaints... (I don't know about the rest of you, but it seems to
>
happen that way to me a lot).
Completely agree with this!
>
also, if you are sending the message [[self document] niceMessage] in
>
MyWindowController.m, then you are trying to send the niceMessage to a
>
instance of MyWindowController, and not MyDocument.
The way I read the original poster's note, he is using the "Cocoa
Document-based App" project template; therefore his MyWindowController
class is likely to be a subclass of NSWindowController. As such it
already knows how to respond to a -document message by returning its
NSDocument object (which in this case should be an instance of his
MyDocument subclass. Then, [self document] asks the window controller to
return its associated document object, and this is in turn the receiver
of the -niceMessage message.
>
If you have an instance in you nib file of a MyWindowController and a
>
MyDocument, you can creat an outlet from MyDocument, containing a
>
pointer to
>
it's self, and have the MyWindowController keep track of that pointer,
>
then
>
you could have MyWindowController send messages to MyDocument.
Again, if he's following the Cocoa document-based project template
model, the MyWindowController subclass is (or ought to be) the nib's
File's Owner, so it doesn't need to be instantiated to originate or
receive connections. In any case, the NSDocument takes care of
establishing the connection between itself and its window controller(s),
so this requires no action on the part of the IB user. As those Apple
people like to say, "It just works."