Re: Global Variables
Re: Global Variables
- Subject: Re: Global Variables
- From: Michael Crawford <email@hidden>
- Date: Wed, 23 Mar 2005 06:17:53 -0800
I agree. What you really need to do is figure out what behavior is
associated with what data. If, after performing this analysis, you
still have some global data (and behavior) that you want to make
accessible to multiple parts of the system, consider binding (not Cocoa
Bindings) the data and the behavior together as a Singleton. Here is
the first hit from Google on the definition of the Singleton design
pattern. If you need more information Google is your friend.
http://www.dofactory.com/Patterns/PatternSingleton.aspx
On Mar 21, 2005, at 9:31 PM, BlueHorseshoe wrote:
On Mar 22, 2005, at 12:19 AM, Adam wrote:
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?
Yes, NSString's or any other C struct can be declared "extern," but as
Mr. Deadman suggests you are embarking on a bad design.
I would suggest that you assign one class some kind of ownership role
for these shared variables and then use normal methods for the other
classes to access it.
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Cocoa-dev mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
email@hidden
This email sent to email@hidden
_______________________________________________
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