• 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
best practices for globals/identifiers in a Cocoa app
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

best practices for globals/identifiers in a Cocoa app


  • Subject: best practices for globals/identifiers in a Cocoa app
  • From: John Clayton <email@hidden>
  • Date: Sun, 09 Nov 2003 19:50:42 -0500

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? I was thinking maybe a protocol that the client class would implement and gain access to these variables, but unsure of the implications of that. It seems a waste to declare a class just for its fields.

I've looked through our list carefully and found some hints, but nothing definitive. Doing a revue of open source Cocoa code now to try and learn a few tricks, like an old dog.

Well, anyway, thanks ;-)

John

-----------------------------------------------------------
No clever signature goes unpunished.
-----------------------------------------------------------
_______________________________________________
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.

  • Follow-Ups:
    • Re: best practices for globals/identifiers in a Cocoa app
      • From: Chris Hanson <email@hidden>
    • Re: best practices for globals/identifiers in a Cocoa app
      • From: Alastair Houghton <email@hidden>
  • Prev by Date: NSArrayController population
  • Next by Date: Drag and drop slide back speed
  • Previous by thread: Re: NSArrayController population
  • Next by thread: Re: best practices for globals/identifiers in a Cocoa app
  • Index(es):
    • Date
    • Thread