FROM : Sherm Pendley
DATE : Tue Dec 21 16:51:34 2004
On Dec 21, 2004, at 3:40 AM, Kiel Gillard wrote:
> not using them in the header file, I may use 1 of the strings in the
> implementation file. However, when I compile my program, the compiler
> displays warnings telling me that I haven't used the strings.
... snip ...
> static NSString * MY_CONSTANT_STRING = @"I want to";
> static NSString * ANOTHER_CONSTANT_STRING = @" work for Apple";
These shouldn't be declared as static - that limits their visibility to
a single file. To make them truly constant, declare them like this in
Constants.h:
extern NSString * const MY_CONSTANT_STRING;
extern NSString * const ANOTHER_CONSTANT_STRING;
Then define their values in Constants.m:
NSString * const MY_CONSTANT_STRING = @"I want to";
NSString * const ANOTHER_CONSTANT_STRING = @"work for Apple";
sherm--
Cocoa programming in Perl: http://camelbones.sourceforge.net
Hire me! My resume: http://www.dot-app.org
DATE : Tue Dec 21 16:51:34 2004
On Dec 21, 2004, at 3:40 AM, Kiel Gillard wrote:
> not using them in the header file, I may use 1 of the strings in the
> implementation file. However, when I compile my program, the compiler
> displays warnings telling me that I haven't used the strings.
... snip ...
> static NSString * MY_CONSTANT_STRING = @"I want to";
> static NSString * ANOTHER_CONSTANT_STRING = @" work for Apple";
These shouldn't be declared as static - that limits their visibility to
a single file. To make them truly constant, declare them like this in
Constants.h:
extern NSString * const MY_CONSTANT_STRING;
extern NSString * const ANOTHER_CONSTANT_STRING;
Then define their values in Constants.m:
NSString * const MY_CONSTANT_STRING = @"I want to";
NSString * const ANOTHER_CONSTANT_STRING = @"work for Apple";
sherm--
Cocoa programming in Perl: http://camelbones.sourceforge.net
Hire me! My resume: http://www.dot-app.org
| Related mails | Author | Date |
|---|---|---|
| Kiel Gillard | Dec 21, 09:40 | |
| Sherm Pendley | Dec 21, 16:51 |






Cocoa mail archive

