Re: import statement issues
Re: import statement issues
- Subject: Re: import statement issues
- From: Peter Fischer <email@hidden>
- Date: Thu, 3 Apr 2003 17:59:20 -0500
Andrew-
I'm a bit of a cocoa newbie, so take my advice with a grain of salt.
It appears like you have dependancy issue, i.e. x depends on y, and
y depends on x. If each one depends on the other, the compiler is not
able to fully parse Hex.h or Force.h without referencing one another.
To get around this, you can do a forward declaration. For example.
In Force.h
@class Hex;
@interface Force : NSObject
{
Hex *hex;
...
in Hex.h
@class Force;
@interface Hex : NSObject
{
Force *force;
...
In Force.m import Hex.h, and in Hex.m import Force.h. As long the
instance variables are pointers, you should have no problems.
--Pete
On Thursday, April 3, 2003, at 03:13 PM, Andrew Kinnie wrote:
OK, I'm apparently an idiot. I am trying to develop a strategy game.
I have several of my own custom classes, e.g. Hex, Force, etc. A Hex
can have a Force, and a Force must be in a Hex. I therefore have
instance variable in each: Force has an instance variable hex of type
Hex, and Hex has an instance variable force of type Force.
I have created new Cocoa Obj-C files (.h and .m) for these in my
project. However, when I tried to compile, I get
Force.h:20: undefined type, found `Hex'
etc. I added an
#import "Hex.h"
below the normal cocoa import statement. I still get the error.
Likewise for Hex.h, I add
#import "Force.h"
What idiotic thing am I missing???
Andrew
_______________________________________________
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.
_______________________________________________
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.