Re: Creating a Constants.h file
Re: Creating a Constants.h file
- Subject: Re: Creating a Constants.h file
- From: Sherm Pendley <email@hidden>
- Date: Tue, 21 Dec 2004 10:51:34 -0500
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
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Cocoa-dev mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden