• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Re: Creating a Constants.h file
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

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


References: 
 >Creating a Constants.h file (From: "Kiel Gillard" <email@hidden>)

  • Prev by Date: Re: wrong date value from safari's lastVisitedDate in History.plist
  • Next by Date: Re: Value transformers and app delegates
  • Previous by thread: Creating a Constants.h file
  • Next by thread: NSButton without background
  • Index(es):
    • Date
    • Thread