• 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 variable for whole application.
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Global variable for whole application.


  • Subject: Re: Global variable for whole application.
  • From: "Shawn Erickson" <email@hidden>
  • Date: Wed, 18 Apr 2007 08:02:30 -0700

On 4/18/07, Filipe Varela <email@hidden> wrote:
no matter what you're trying to do, that's a very very bad design.
you can't possibly need an application-wide global variable. use
classes, accessors, notifications, delegation, etc

Global _constants_ are common and reasonable to do... just look at the Cocoa.framework for countless examples.

For example I do things like the following in my code all the time

In .h file...
// Participant database notification name constants
extern NSString* const kParticipantDB_ParticipantJoined;
extern NSString* const kParticipantDB_ParticipantLeft;
...

In .m / .mm file...
NSString* const kParticipantDB_ParticipantJoined = @"Participant_Joined";
NSString* const kParticipantDB_ParticipantLeft = @"Participant_Left";
...

Use of #defines for constants has its uses but it also has it limits
and weaknesses. I personally wouldn't recommend their use with any
type of generic statement.

-Shawn
_______________________________________________

Cocoa-dev mailing list (email@hidden)

Do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden


  • Follow-Ups:
    • Re: Global variable for whole application.
      • From: Filipe Varela <email@hidden>
References: 
 >Global variable for whole application. (From: "Jay" <email@hidden>)
 >Re: Global variable for whole application. (From: Filipe Varela <email@hidden>)

  • Prev by Date: Re: Bindings of NSMutableArray of NSMutableArray
  • Next by Date: CoreData, NSPredicate, searching for object with a specific number objects of relationships
  • Previous by thread: Re: Global variable for whole application.
  • Next by thread: Re: Global variable for whole application.
  • Index(es):
    • Date
    • Thread