Reputation: 990
Today when I opened up Xcode project and built it for the iOS simulator. Everything was working fine yesterday but this morning there is a compilation error.
The following line is highlighted red in a header file and the message next to it says "Expected a type".
-(void) addObstacle:(Obstacle*) obstacle;
The bit of code hasn't changed in a few days so I'm not really sure why theres now an error.
I have imported Obstacle.h and this is the Obstacle class header:
#import "kobold2d.h"
@interface Obstacle : CCNode {
int posXInGrid;
int posYInGrid;
CCSprite* sprite;
}
@property (nonatomic) int posXInGrid;
@property (nonatomic) int posYInGrid;
@property (nonatomic, retain) CCSprite* sprite;
@end
Upvotes: 4
Views: 8496
Reputation: 64477
Move #import "Obstacle.h"
from the interface (.h) to the implementation file (.m).
Then add @class Obstacle; at the top of the interface file.
If this fixes the problem you do have a circular import. See here to learn why this fixes it. @class is preferable over #importing class headers whenever possible.
Upvotes: 6