繁体   English   中英

Objective-C:预期类型错误

[英]Objective-C: Expected a type error

我正在尝试按照Nick Kuh的“ iPhone App Development”一书中的样式表使用教程。 样式表头文件抛出:

“预期类型”

我认为通常反映出循环问题的错误。 但是,在这种情况下,唯一的导入是到Foundation.h。 (实现文件btw不会引发任何错误,似乎还可以。)这是完整的头文件。

#import <Foundation/Foundation.h>

typedef enum : int {
    IDLabelTypeName = 0,
    IDLabelTypeBirthdayDate,
    IDLabelTypeDaysUntilBirthday,
    IDLabelTypeDaysUntilBirthdaySubText,
    IDLabelTypeLarge
}
IDLabelType;

@interface IDStyleSheet : NSObject
+(void)initStyles;

+(void)styleLabel:(UILabel *)label withType:(IDLabelType)labelType;//throws red error

+(void)styleTextView:(UITextView *)textView;//throws red error
+(void)styleRoundCorneredView:(UIView *)view;//throws red error


@end

谁能看到为什么会发生这些错误?

UILabelUITextView ...是在UIKit框架中定义的,因此您必须

#import <UIKit/UIKit.h>

(然后隐式导入Foundation)。 您还可以使用更现代的“模块”语法:

@import UIKit;

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM