0

这是我的 Board 头文件:

#import "Game.h"
#import <Foundation/Foundation.h>

@interface Board : UIView
{
    enum Piece;
}

- (void) setGame: (Game*) theGame; //<-- this is where the error is
typedef enum {X, O, NONE} Piece;
- (float)getSection;
@end

编译器说“期望一个类型”并在 (Game*) 下划线。这里有什么问题?


游戏.h:

#import <Foundation/Foundation.h>
#import "Board.h"

@interface Game : UIViewController

- (void)boardwasTapped:(int) row:(int) column;

@end
4

2 回答 2

1

不要导入您的标头,而是转发声明它。在 Board.m 中导入游戏标头

@class Game;

@interface Board : UIView {
...
}
...
@end

另外,您确定问题不在于您的枚举吗?在声明它之前,您在标题中使用它。您应该在 @interface 块上方(外部)声明它。

于 2012-10-25T17:59:53.423 回答
1

棋盘导入游戏,游戏导入棋盘。所以你需要在 Board 中转发类 Game

@Class Game
于 2012-10-25T18:28:51.323 回答