【问题标题】:Mysterious "Unknown type name" error神秘的“未知类型名称”错误
【发布时间】:2012-08-21 18:07:10
【问题描述】:

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

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 声明中的“预期类型”。就好像 GQEncounter 根本不包含在文件中。我使用 xcode 4.4.1。我什至重新安装它试图摆脱这个问题,但它没有帮助。

这里发生了什么?

【问题讨论】:

标签: objective-c xcode


【解决方案1】:

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

【讨论】:

    猜你喜欢
    • 2012-02-20
    • 2016-06-14
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2011-12-29
    • 2013-10-12
    相关资源
    最近更新 更多