简体   繁体   中英

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" . 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. (The implementation file, btw, does not throw any errors and seems to be fine.) Here is the header file in its entirety.

#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

#import <UIKit/UIKit.h>

(which then implicitly imports Foundation). You can also use the more modern "module" syntax:

@import UIKit;

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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