FROM : Mark Teagarden
DATE : Thu Mar 06 19:16:46 2008
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
DATE : Thu Mar 06 19:16:46 2008
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
| Related mails | Author | Date |
|---|---|---|
| Mark Teagarden | Mar 6, 19:16 | |
| David | Mar 6, 19:44 | |
| Paul Goracke | Mar 6, 20:19 | |
| Mark Teagarden | Mar 6, 21:00 | |
| Paul Goracke | Mar 6, 21:31 |






Cocoa mail archive

