[英]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
誰能看到為什么會發生這些錯誤?
UILabel
, UITextView
...是在UIKit框架中定義的,因此您必須
#import <UIKit/UIKit.h>
(然后隱式導入Foundation)。 您還可以使用更現代的“模塊”語法:
@import UIKit;
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.