[英]NS_ENUM error when declared before class instance variables
.h文件示例:
@interface MyClass : NSObject
typedef NS_ENUM(int, myType) {
Something,
SomethingElse,
SomethingElseElse,
YetAnotherSomethingElse
};
{ //Error On This Line: Expected Identifier or '('
int aInstanceVariable;
}
//Some Methods go here
@end
為什么會出現該錯誤(請參見上面代碼中的注釋)? 在類實例變量聲明下方時,它可以正常工作,但我想將其用作我的實例變量之一的類型。
感謝@CarlVeazey,我發現答案很簡單:將typedef
聲明移到@interface
上方。 這樣做的原因是類型不能由類或類的實例擁有,因此不能在類的接口中。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.