Re: best practices for globals/identifiers in a Cocoa app
Re: best practices for globals/identifiers in a Cocoa app
- Subject: Re: best practices for globals/identifiers in a Cocoa app
- From: Alastair Houghton <email@hidden>
- Date: Mon, 10 Nov 2003 01:11:14 +0000
On 10 Nov 2003, at 00:50, John Clayton wrote:
>
Hi,
>
>
When using strings and such as identifiers, especially when tying into
>
interface elements like a table column name, or in user defaults as
>
keys, etc., I have been in the practice of doing something like this:
>
>
MyClass.h
>
>
extern NSString * myIdent ;
>
>
MyClass.m
>
>
NSString* myIdent = @"the_name_of_something";
>
>
and then using the variable in place of the actual string.
>
>
This works fine, except that the amount of these things is growing
>
rather large and keeping them in my app delegate like I have been
>
doing seems cumbersome. Is there an acceptable way to keep them in a
>
separate file?
Just create another .m file in your project, and put them in there.
You could call it "strings.m" or something similar. This is exactly
the same thing you might do in a C program in similar circumstances.
As for which header they live in, you can leave them where they are at
the moment, or you could move them to a separate header... it really
doesn't matter. (Remember, there is no link between header file name
and implementation file name other than the one you have in your
head... the compiler does not care what you call your files [as long as
they have extensions it recognises].)
Kind regards,
Alastair.
[demime 0.98b removed an attachment of type application/pkcs7-signature which had a name of smime.p7s]
_______________________________________________
cocoa-dev mailing list | email@hidden
Help/Unsubscribe/Archives:
http://www.lists.apple.com/mailman/listinfo/cocoa-dev
Do not post admin requests to the list. They will be ignored.