I have the following Objective-C headers:
// Menu.h
#import <UIKit/UIKit.h>
#import "GameController.h"
@interface Menu : UIImageView {
GameController *gameController; // "Expected specifier-qualifier-list
// before GameController"
}
- (void)appear;
@end
and
// GameController.h
#import <UIKit/UIKit.h>
#import "Menu.h"
@interface GameController : UIView {
Menu *menu; // "Unknown type name 'Menu'"
}
- (void)startLevel0;
- (void)startLevel1;
- (void)startLevel2;
@end
When I try to build the project, Xcode (v4) yells at me, saying Expected specifier-qualifier-list before GameController
and unknown type name 'Menu'
. I'm sure that they are somehow related, but I have no idea how?
It's not good practice to have mutually-including header files. Instead of importing Menu.h, use the
@class
directive. Try removing#import "Menu.h"
and adding@class Menu
in its place. Ditto for Menu.h (remove GameController include, and add the@class
directive)