Re: A niceMessage in MyDocument
Re: A niceMessage in MyDocument
- Subject: Re: A niceMessage in MyDocument
- From: Ivan Myrvold <email@hidden>
- Date: Wed, 20 Jun 2001 07:50:21 +0400
Yes, the compiler complaints went away, when I imported MyDocument.h.
Silly me!
I still have the problem of the NSLog returning "null", but I will
slowly go through all your suggestions.
Ivan
On Wednesday, June 20, 2001, at 03:19 AM, 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).
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?
_______________________________________________
cocoa-dev mailing list
email@hidden
http://www.lists.apple.com/mailman/listinfo/cocoa-dev