为什么这段代码不能用于从类中引用 const?
背景:我希望能够在类变量类型方法中从类中引用常量值,因为这是有意义的来源。试图找到有效地让类提供暴露常量的最佳方法。我尝试了以下方法,但它似乎不起作用,我得到“错误:在'DetailedApppointCell'类型的对象上找不到属性'titleLablePrefix'”
@interface DetailedAppointCell : UITableViewCell {
}
extern NSString * const titleLablePrefix;
@end
#import "DetailedAppointCell.h"
@implementation DetailedAppointCell
NSString * const titleLablePrefix = @"TITLE: ";
@end
// usage from another class which imports
NSString *str = DetailedAppointCell.titleLablePrefix; // ERROR: property 'titleLablePrefix' not found on object of type 'DetailedAppointCell'