简体   繁体   English

Objective-C:预期类型错误

[英]Objective-C: Expected a type error

I am trying to follow a tutorial for using a stylesheet from Nick Kuh's book "iPhone App Development" . 我正在尝试按照Nick Kuh的“ iPhone App Development”一书中的样式表使用教程。 The stylesheet header file is throwing: 样式表头文件抛出:

"Expected a type" “预期类型”

errors which I think normally reflects a circular problem. 我认为通常反映出循环问题的错误。 However, in this case the only import is to Foundation.h. 但是,在这种情况下,唯一的导入是到Foundation.h。 (The implementation file, btw, does not throw any errors and seems to be fine.) Here is the header file in its entirety. (实现文件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

Can anyone see why these errors are occurring? 谁能看到为什么会发生这些错误?

UILabel , UITextView ... are defined in the UIKit framework, therefore you have to UILabelUITextView ...是在UIKit框架中定义的,因此您必须

#import <UIKit/UIKit.h>

(which then implicitly imports Foundation). (然后隐式导入Foundation)。 You can also use the more modern "module" syntax: 您还可以使用更现代的“模块”语法:

@import UIKit;

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

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