Objective c 标题中的typedef导致错误“;在'之前应为说明符限定符列表;typedef'&引用;
亲爱的互联网智慧 在头文件中(Objective-C) myTestClass.hObjective c 标题中的typedef导致错误“;在'之前应为说明符限定符列表;typedef'&引用;,objective-c,xcode,header,typedef,Objective C,Xcode,Header,Typedef,亲爱的互联网智慧 在头文件中(Objective-C) myTestClass.h #import <Foundation/Foundation.h> @interface myTestClass : NSObject { typedef int pixel; } - (id) initWithPic: (NSString*) picFileName; - (void) dealloc; - (void) doSomething; @end #
#import <Foundation/Foundation.h>
@interface myTestClass : NSObject {
typedef int pixel;
}
- (id) initWithPic: (NSString*) picFileName;
- (void) dealloc;
- (void) doSomething;
@end
#导入
@接口myTestClass:NSObject{
typedef int像素;
}
-(id)initWithPic:(NSString*)picFileName;
-(无效)解除锁定;
-(无效)剂量测定;
@结束
在行typedef int pixel处代码>xCode抱怨类似
(!)“之前应为说明符限定符列表
“类型定义”(3)
这个err-msg看起来很流行,但给定的解决方案(缺少导入)对我来说不起作用。
我发现的提示也不能解释这里出了什么问题
我不明白这个错误
有人能给我解释一下吗
我非常感谢您提供的任何提示。不确定您想做什么,请将您的输入放在您的界面之前
支架内是IVAR的位置
如果需要整数变量,则不需要typedef:
@interface MyClass
{
int myPixel;
}
@end
typedef用于基于另一个类型创建新类型。例如:
typedef int pixel;
@interface MyClass
{
pixel myPixel;
}
@end
因此,当您使用pixel
伪类型时,将使用int
类型。OK,因此代码是正确的,“只是”位置错误。应该知道,现在已经很晚了(欧洲),所以我不再关心err msg的意思了,我想让我的返回类型人性化,就像你的第二个例子中的替换一样。谢谢你的快速回答