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: Chris Hanson <email@hidden>
- Date: Mon, 10 Nov 2003 08:32:39 -0600
On Nov 9, 2003, at 6:50 PM, John Clayton wrote:
NSString* myIdent = @"the_name_of_something";
Just so you know, you should be using proper Cocoa instance variable
style for strings that used as things like user defaults keys and
column identifiers:
NSString *NBTheNameOfSomething = @"theNameOfSomething";
Why? So you can be sure to be Key-Value Coding compliant. KVC
compliance is important if you want to be able to use the NSController
architecture, or your own generic data-driven controller architecture.
It's definitely acceptable to put your identifier strings in a separate
header file. Note that global or static strings are *not* bound to a
class in Objective-C, and you can have a .h or .m file without a class
in the language as well. The compiler only keys off the source (not
header) file name to figure out what language it's compiling, it
doesn't care about anything deeper than that.
-- Chris
--
Chris Hanson, bDistributed.com, Inc. | Email: email@hidden
Outsourcing Vendor Evaluation | Phone: +1-847-372-3955
Custom Mac OS X Development | Fax: +1-847-589-3738
http://bdistributed.com/ | Personal Email: email@hidden
_______________________________________________
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.