Re: Why the warnings or errors?
Re: Why the warnings or errors?
- Subject: Re: Why the warnings or errors?
- From: email@hidden
- Date: Tue, 20 Apr 2004 07:44:10 -0400
>
So being the person that I am, I do a hacky way around it and replace
>
"IBOutlet Controller * appController;" with "id appController;" and
>
similarly with the Controller.h file, replace "IBOutlet AnotherObject *
>
foo;" with "IBOutlet id foo;" and what do you know? It damn well works!
Your problem here is that both classes are trying to statically type instances
of each other - but the compiler can obviously only deal with one file at a
time - so when it is dealing with the first header file, it doesn't yet know
anything about the second one. The way around this is to use the '@class'
directive in the interface files. This is basically just a promise from you to
the compiler that such and such a class will exist once it's finished
compiling. The directive goes between #import <Cocoa/Cocoa.h> and the
@interface line. I suggest you put one in both of your header files.
ie. In "AnotherObject.h":
@class Controller
and in "Controller.h":
@class AnotherObject
>
>
So when you start adding methods that are called from the other object,
>
warnings start to pile up. You'll get messages near identical to
>
"cannot find method `-<method name>'; return type `id' assumed." Or at
>
least I do. But the methods still execute and return values, etc.
>
The other issue I think you're having is that, given the description of the
files you imported - your classes are only aware of their own methods. If you
want the classes to communicate, they'll have to import each other's header
files in the .m files in order to know which methods are valid calls.
Hope this helps!
-grayden
----------------------------------------
This mail sent through www.mywaterloo.ca
_______________________________________________
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.