开发者

objective c import once

I have a header file with a bunch on statics like

static NSString * SOME_NAME = @开发者_StackOverflow社区"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...


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.


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.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜