• 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: Global Variables
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Global Variables


  • Subject: Re: Global Variables
  • From: Charilaos Skiadas <email@hidden>
  • Date: Mon, 21 Mar 2005 23:24:46 -0600

On Mar 21, 2005, at 11:06 PM, Johnny Deadman wrote:

Alternatively, if it isn't something the user should be able to change, you can declare it as 'extern' as Rakka describes, which is what Apple do for their constant strings and so on.

I find it convenient to hard-code all strings I use as keys to dictionaries as #define's. Helps a lot with debugging. If you mistype a string, you get a compile error, instead of a nil object that would be too hard to track down.


In my prefix.pch file, I put stuff like:
#define CHSProgramName @"ProgramName"
#define CHSProgramCode @"ProgramCode"
#define CHSExtensionName @"ExtensionName"
#define CHSPath @"Path"
#define CHSArguments @"Arguments"
#define CHSChecked @"Enabled"
#define CHSInputPrompt @"InputPrompt"
#define CHSManuallyAddInput @"ManuallyAddInput"

And then use the CHS.. instead of the strings. Works like a charm.
Haris

_______________________________________________
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


  • Follow-Ups:
    • Re: Global Variables
      • From: Charilaos Skiadas <email@hidden>
References: 
 >Global Variables (From: Adam <email@hidden>)
 >Re: Global Variables (From: Johnny Deadman <email@hidden>)

  • Prev by Date: Re: Global Variables
  • Next by Date: Re: Global Variables
  • Previous by thread: Re: Global Variables
  • Next by thread: Re: Global Variables
  • Index(es):
    • Date
    • Thread