Re: class variables and class methods
Re: class variables and class methods
- Subject: Re: class variables and class methods
- From: lbland <email@hidden>
- Date: Wed, 7 Jan 2004 20:02:12 -0500
On Jan 7, 2004, at 7:04 PM, Robert Goldsmith wrote:
I assume that, if it is in the .m file, a static variable has the scope
of that file. If it is not static, it's scope is what? Global? If it is
in the .h file and static, what would it's scope be?
It's normal ANSI-C, so file scope.
No, not "easy", other than the way you just did it.
Ok, so at compile time, if there is a method that uses a static
variable, it is compiled down to use that variable even though a
subclass inherits the method and has it's own static variable :( In
other words, file scope static beats class scope static :(
If you need inheritance properties in class scope, do it using a class
accessor on the static variable, ie:
in .h file:
+ (int)myClassVariable;
in .m file:
static int myClassVariable = 0;
+ (int)myClassVariable {return myClassVariable;}
-lance
_______________________________________________
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.