Re: A niceMessage in MyDocument
Re: A niceMessage in MyDocument
- Subject: Re: A niceMessage in MyDocument
- From: "Joshua D. Orr" <email@hidden>
- Date: Tue, 19 Jun 2001 17:19:16 -0600
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).
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.
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.
-Joshua D. Orr-
>
My next dumb question to this group, for my Document Based application:
>
>
In MyDocument.h I have:
>
- (NSString *)niceMessage;
>
>
In MyDocument.m I have:
>
- (NSString *)niceMessage {
>
return @"Nice Greeting!";
>
}
>
>
In MyWindowController.m in one of my methods:
>
>
NSLog(@"The Message: %@", [[self document] niceMessage]);
>
>
>
The compiler complaints about the above, saying:
>
warning: cannot find method (pointing to the NSLog line).
>
warning: return type for 'niceMessage' defaults to id (for the same
>
line)
>
>
And running the application, I get the following in the console:
>
The Message: (null)
>
>
>
The documentation says:
>
>
As a convenience, the Objective-C language also supports the @"..."
>
construct to create ....
>
Such an object is created at compile time and exists throughout your
>
program's execution. The compiler makes such an object constants unique
>
on a per-module basis, and they're never deallocated (though you can
>
retain and release them as you do any other object).
>
>
>
So why does I get a null in the console, and what about the compiler
>
complaints?