Re: Global Variables
Re: Global Variables
- Subject: Re: Global Variables
- From: Charilaos Skiadas <email@hidden>
- Date: Mon, 21 Mar 2005 23:29:17 -0600
Sorry, disregard my previous post. I just realized we are talking about
variables, not constants. (Yes, I know the thread's name says so.)
Externs seems the way to go, unless it actually makes sense to
construct a sharedConstantDictionary class, which sounds like a bit of
an overkill.
Haris
On Mar 21, 2005, at 11:24 PM, Charilaos Skiadas wrote:
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:
email@hidden
This email sent to email@hidden
_______________________________________________
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