Why the warnings or errors?
Why the warnings or errors?
- Subject: Why the warnings or errors?
- From: Kiel Gillard <email@hidden>
- Date: Tue, 20 Apr 2004 18:48:01 +1000
Hi guys!
My Cocoa program that I'm making doesn't like me ie: I've probably done
something wrong that I'm not aware of. I'm fairly new to
Cocoa/Objective-C. More specifically, I get warnings about every
method/property I attempt to access in my controller outside of the
object I'm accessing it from that say "cannot find method `<method
name>'; return type `id' assumed." Yet, it works fine during runtime.
The good news is I can recreate the problem and I would like to know if
you guys could please point out what I'm doing wrong. The bad news is I
cannot seem to get rid of the problem without the compiler reporting an
error.
I create a new project, name it "test" or something, open up the
mainmenu.nib file, I create two objects, namely "Controller" and
"AnotherObject." Then, I create an outlet in the object "AnotherObject"
called "appController" of type "Controller." For the Controller, I
create an outlet titled "foo" of type "AnotherObject". I then
instantiate both these objects and link them up to eachother; ie:
control drag a line from controller to another object and vice versa.
I then create files for each of my object I have created (Controller
and AnotherObject), wander off into Xcode and in the header for
Controller, I type
#import "Controller.h" in AnotherObject's header file (with the #import
<Cocoa/Cocoa.h> line) and #import "AnotherObject.h" in the Controller's
header file.
If I the hit Command R, it won't take it. 1 error - and it's either
'parse error before 'Controller'' or 'parse error before
'AnotherObject''. Ok, that's strange. I have no idea what it doesn't
like about that.
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!
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.
I'm concerned my tolerance for the now 25-odd warnings is a bad thing
and my naivety will come around and haunt me. If any of you have the
time, could you please point out what am I doing wrong (other than
using and id variable in the .h files)? Why does #import <a header file
of another object> cause the program not to compiler in the other
classes that need to use the object?
TIA,
Kiel ;-)
"Some people make the world special by just being in it"
My grandparent's fridge
_______________________________________________
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.