我在某些我認爲很簡單的事情上遇到了一個非常奇怪的錯誤。目標C - 錯誤:'預期類型'
#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
EDIT 2 **
和ViewController.h文件
#import <GLKit/GLKit.h>
#import "GameController.h"
@interface ViewController : GLKViewController
@end
如何定義ViewController? – Wain
這可能會幫助你,類似的問題:http://stackoverflow.com/a/9607607/1422070 – edwardmp
也許在.h文件中你拼錯了類名。 –