Hi,

My app has three objects - world, mapview, and game, and they need to know
about each other in various combinations: mapview needs an outlet to world
and game, and game needs an outlet to world.  I've ctrl-clicked them all
together appropriately in IB, and now I'm trying to declare the IBOutlets in
code.  So in mapview.h:

#import <Cocoa/Cocoa.h>
#import "World.h"
#import "Game.h"

@interface WMapView : NSView {
    IBOutlet Game * game;
    IBOutlet World * world;
    int view_x, view_y, window;

}

This worked fine and complied correctly.  But the following code (identical,
as far as I can tell) in game.h:

#import <Cocoa/Cocoa.h>
#import "World.h"

@interface Game : NSObject {
    IBOutlet World * world;
}

Throws up: 'syntax error before World' in the IBOutlet statement.  I was
able to get around this by replacing

#import "World.h" 

with 

@class World

in game.h.

I have another class, Display, that gives me the same error as the one in
game.h - I've omitted it here for clarity.  Basically, the mapview.h #import
/ IBOutlet is the only one that worked correctly.

My questions are:
1.  Why does identical code work in one file and not in the others?
2.  Why should @class work when #import doesn't?  Hillegass flat out says
that the two are interchangeable.

Thanks,
Mark


_______________________________________________

Cocoa-dev mailing list ([email protected])

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to [EMAIL PROTECTED]

Reply via email to