Re: A niceMessage in MyDocument
Re: A niceMessage in MyDocument
- Subject: Re: A niceMessage in MyDocument
- From: John Hörnkvist <email@hidden>
- Date: Wed, 20 Jun 2001 02:53:55 +0200
On Wednesday, June 20, 2001, at 01:19 AM, Joshua D. Orr wrote:
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.
No; [self document] returns the document that the window controller
belongs to (an object which we expect to be an instance of the
MyDocument class).
[[self document] niceMessage] will send a message to a document object.
When NSLog(@"Message: %@",[[self document] niceMessage]) give a result
like
"Message: nil" then I'd throw in an assertion;
assert([self document]);
to check that the window controller has a document associated with it.
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.
(I'm not sure what the above means, but I have a strong feeling that
it's wrong. ;-))
If the window controller has been added to the window with any of the
standard methods, (addWindowController:), then I'm quite certain that
the window controller will be made aware of the document. No need to
involve InterfaceBuilder.
Regards,
John Hornkvist
--
ToastedMarshmallow, the perfect Cocoa companion
http://www.toastedmarshmallow.com