【问题标题】:Enumerator Type not recognised in interface接口中无法识别枚举器类型
【发布时间】:2014-08-07 13:02:40
【问题描述】:

我有一个标头 (@interface),我在其中声明了一个枚举器。

我将该枚举器的类型作为 initWithDelegate 构造函数的参数引用,但 XCode 不认为它是有效类型。

我会很感激对此的一些建议。

代码如下:

#import <Foundation/Foundation.h>

@interface ReportLoader : NSObject

@property (nonatomic, strong) NSString* fileKey;

//Issue with this line at the pReportType parameter declaration.
-(NSObject*)initWithDelegate:(NSObject*)pDelegate andService:(ServiceReference*)pService andFileKey:(NSString*)pKey andReportType:(ReportType)pReportType;

typedef enum ReportTypes
{
    GridReport = 1,
    TableReport = 2,
    FlowReport = 3,
}ReportType;

@end

【问题讨论】:

    标签: objective-c xcode enums


    【解决方案1】:

    如果您对枚举使用typdef,则无法声明前向声明(就像您对稍后声明的类使用@class)。

    解决这个问题的最简单方法是将枚举定义放在最上面,在你使用它的函数之上。

    【讨论】:

      猜你喜欢
      • 2021-10-24
      • 1970-01-01
      • 2017-05-22
      • 1970-01-01
      • 1970-01-01
      • 2021-08-28
      • 1970-01-01
      • 1970-01-01
      • 2020-03-03
      相关资源
      最近更新 更多