• 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 Variables
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Global Variables


  • Subject: Re: Global Variables
  • From: Adam <email@hidden>
  • Date: Tue, 22 Mar 2005 00:19:22 -0500

I know including it in every class is overkill, but I have variables that 3 or 4 classes share and I am constantly changing them in multiple places. Will an extern work with cocoa code like NSString?


Adam

On Mar 22, 2005, at 12:06 AM, Johnny Deadman wrote:

I would say the best thing is to ask yourself why you want to do this. Very few properties need to be accessible by every single class.

For properties that really do need to be available everywhere, like the units your user prefers to use, then make it a user default if appropriate:

http://developer.apple.com/documentation/Cocoa/Conceptual/ UserDefaults/index.html#//apple_ref/doc/uid/10000059i

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.

On 21-Mar-05, at 11:35 PM, Adam wrote:

What is the best way to make a variable globally accessible across all of my obj-c classes?


_______________________________________________ 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
  • Follow-Ups:
    • Re: Global Variables
      • From: BlueHorseshoe <email@hidden>
References: 
 >Global Variables (From: Adam <email@hidden>)
 >Re: Global Variables (From: Johnny Deadman <email@hidden>)

  • Prev by Date: Re: Global Variables
  • Next by Date: Re: Global Variables
  • Previous by thread: Re: Global Variables
  • Next by thread: Re: Global Variables
  • Index(es):
    • Date
    • Thread