神秘的“未知类型名称”错误

时间:2012-08-21 18:07:11

标签: objective-c xcode

我有一个非常简单的代码。我怀疑它的大部分内容是无关的,但是由于我对这个问题感到困惑,我决定按原样包含源代码。

GQEncounter.h:

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

@interface GQEncounter : NSObject {
    NSArray *roughOptions;
    NSString *roughText;
}

@property (readonly) NSArray *options;
@property (readonly) NSString *text;

- (id) initFromDictionary:(NSDictionary *) dict;
- (void) executeOption:(NSInteger) number;

@end

GQEncounterViewController.h:

#import <UIKit/UIKit.h>
#import "GQEncounter.h"

@interface GQEncounterViewController : UIViewController {

    GQEncounter *_encounter;
    UILabel *encounterText;
    NSArray *encounterButtons;
    CGRect _rect;

}

- (id)initWithEncounter:(GQEncounter *)encounter
                   rect:(CGRect)rect;
- (void)chooseOption:(UIButton *)button;

@end

正如您所看到的,它非常简单。但是,由于某些未知原因,xcode在GQEncounterViewController文件中显示错误:_encounter变量声明中的“未知类型名称'GQEncounter'”和initWithEncounter声明中的“Expected a type”。就好像GQEncounter根本没有包含在文件中一样。我使用xcode 4.4.1。我甚至重新安装它试图摆脱这个问题,但它没有帮助。

这里发生了什么?

1 个答案:

答案 0 :(得分:2)

我不确定您为什么在GQEncounterViewController文件中有GQEncounter.h导入语句,但尝试将其移出,如果您确实需要,请使用@class GQEncounterViewController;代替

相关问题