【发布时间】:2013-07-11 13:58:07
【问题描述】:
我在一些我认为很简单的事情上遇到了一个非常奇怪的错误。
#import <Foundation/Foundation.h>
#import "ViewController.h"
#import "GameObject.h"
@interface GameController : NSObject
@property (strong) GLKBaseEffect * effect;
@property (strong) NSMutableArray * gameObjects;
@property (strong) NSMutableArray * objectsToRemove;
@property (strong) NSMutableArray * objectsToAdd;
+ (GameController *) sharedGameController;
- (void) tick:(float)dt;
- (void) initializeGame: (ViewController*) viewcontroller;//ERROR: EXPECTED A TYPE
- (void) createObject:(Class) objecttype atPoint:(CGPoint)position;
- (void) deleteObject:(GameObject*) object atPoint:(CGPoint)position;
- (void) manageObjects;
@end
为什么会质疑 'ViewController' 是否是一种类型?这是一个我已经正确实现的类。它也被导入了。
编辑 *
如果有帮助,这里是 ViewController.m 类。
#import "ViewController.h"
@implementation ViewController
- (void)viewDidLoad
{
[super viewDidLoad];
[[GameController sharedGameController] initializeGame:self];
}
@end
编辑 2 **
和 ViewController.h 文件
#import <GLKit/GLKit.h>
#import "GameController.h"
@interface ViewController : GLKViewController
@end
【问题讨论】:
-
ViewController是如何定义的? -
这可能会帮助你,类似的问题:stackoverflow.com/a/9607607/1422070
-
可能在 .h 文件中你拼错了类名。
-
@GradyPlayer 为什么,它已经包含在内了?
#import "ViewController.h"无需转发声明。 -
@DavidRönnqvist 当然不需要名为 ViewController.h 的文件包含 ViewController 类的接口
标签: objective-c import header-files forward-declaration circular-dependency