定义NSString全局常量时出错

时间:2012-10-01 06:49:04

标签: objective-c xcode nsstring

  

可能重复:
  Interface type cannot be statically allocated?

以下是我的代码:

TZNotifications.h
extern NSString *const TZNotificationKeywordAuthentication;

TZNotifications.m
NSString *const TZNotificationKeywordAuthentication = @"NOTIFICATION_KEYWORD_AUTHENTICATION";

但我得到的代码有两个错误:

enter image description here

2 个答案:

答案 0 :(得分:0)

替换'const'并输入声明:

TZNotifications.h

extern const NSString *TZNotificationKeywordAuthentication;

TZNotifications.m

const NSString *TZNotificationKeywordAuthentication = @"NOTIFICATION_KEYWORD_AUTHENTICATION";

答案 1 :(得分:0)

谢谢你们。结果我在我的一个头文件的末尾愚蠢地添加了一个无意义的字符串,导致这个奇怪的错误。对不起...