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
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.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.