0

Possible Duplicate:
Interface type cannot be statically allocated?

Here is my code just like others:

TZNotifications.h
extern NSString *const TZNotificationKeywordAuthentication;

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

But I get two errors with the code like this:

enter image description here

Community
  • 1
  • 1
Tranz
  • 167
  • 1
  • 9
  • Hm, works perfectly fine for me when creating the files with just that content and using them in my program. Could you show the surrounding code? Would seem like some other syntax error makes the compiler choke. – Joachim Isaksson Oct 01 '12 at 07:02
  • I'm just wondering, what is main reason why you could not use the `#define TZNotificationKeywordAuthentication @"NOTIFICATION_KEYWORD_AUTHENTICATION"` for the constant string in this case...? – holex Oct 01 '12 at 07:04
  • @holex Built in NSString contants in Cocoa seem to be defined like that, probably since that allows you to use `==` to compare them (they're all the same object) and you don't need to know whether the constant is an NSString or an enum/int. – Joachim Isaksson Oct 01 '12 at 07:18

2 Answers2

0

Replace 'const' and type declaration:

TZNotifications.h

extern const NSString *TZNotificationKeywordAuthentication;

TZNotifications.m

const NSString *TZNotificationKeywordAuthentication = @"NOTIFICATION_KEYWORD_AUTHENTICATION";
Gloomcore
  • 940
  • 7
  • 11
0

Thank you guys. Turns out I had stupidly add a nonsense string at the end of one of my header files causing this weird error. Sorry about that...

Tranz
  • 167
  • 1
  • 9