views:

66

answers:

2

I have a header file with a bunch on statics like

static NSString * SOME_NAME = @"someMeaning";

What is the best way to import this? Should I define them some other way?

I tried just using the #import statement but any file that imports it gives me a warning saying SOME_NAME defined but not used...

A: 

That's a warning, not an error. It's here to help you find variables you don't need anymore. But that kind of variables should be declared as extern, IMHO.

Macmade
I am trying to keep it all in one file. If I declare it as extern I have a file looking like:extern NSString * SOME_NAME;extern NSString * SOME_NAME = @"someMeaning";kind of weird, right? Or, is there another way?
joels
+4  A: 

Try declaring it in the header file as

extern NSString * const SOME_NAME;

And defining it in some implementation file as

NSString * const SOME_NAME = @"SOME_NAME"

The position of the const keyword is important, because that is what makes the pointer itself a constant.

Abizern