weird undefined types
weird undefined types
- Subject: weird undefined types
- From: Chaz <email@hidden>
- Date: Thu, 6 Jun 2002 13:19:29 -0600
Hello:
I'm having a problem with undefined classes. Consider this scenario:
I have two classes, X and Y. X needs to have an instance of class Y,
and class Y needs to be able to send messages to X, so it needs a
pointer to the class X of which Y is an instance variable. So both
classes need to know about each other. In X.h, I have #import "Y.h" and
in Y.h I have #import "X.h". However, I get an "undefined type, found
'Y'" in X.h and "undefined type, found 'X'" in Y.h. I also get
"undefined type, found 'X'" in another class (the NSDocument class for a
document-based app) that has an instance of X. In Document.h, I also
have #import "X.h". I also get some parse errors, but I think they
generally go hand-in-hand with undefined types.
So, you see, I'm including all the files according to which classes need
to know about them, but I keep getting these errors. I've found a
solution that solves all errors:
In Y.h, I do NOT include X.h, and then everywhere where I refer to the X
class in Y.h and Y.m, I use id instead. It does bring up tons of
warnings about "invalid receiver type 'id *'" and about "passing arg 1
of 'obj_msgSend' from incompatible pointer type," but they all go away
after the first compile.
Any idea why I can't refer to object X in object Y's files as what it
really is?
Thanks,
Chaz
_______________________________________________
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.