Re: import statement issues
Re: import statement issues
- Subject: Re: import statement issues
- From: Harriet Kerry <email@hidden>
- Date: Fri, 4 Apr 2003 12:04:11 -0800 (PST)
Andrew:
I think Peter is right. Also, if you haven't thought
about it yet, one of those critters has to be the
"boss". Someone has to start the application, and then
you have to make object pointers available through
methods or globally accessible variables.
Best of luck,
HK
PS. Again, if anyone has a clue on my question, I
would be most grateful. The question is why a subclass
of NSView loses mouse control when the application
menu has been accessed.
>
FROM: Peter Fischer
>
DATE: 2003-04-04 00:59
>
>
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
Yahoo! Tax Center - File online, calculators, forms, and more
http://tax.yahoo.com
_______________________________________________
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.