Re: Static instance variables and class methods...
Re: Static instance variables and class methods...
- Subject: Re: Static instance variables and class methods...
- From: Jeff LaMarche <email@hidden>
- Date: Sat, 6 Oct 2001 22:56:42 -0700
On Saturday, October 6, 2001, at 10:46 PM, John C. Randolph wrote:
I'm not sure what you mean by a static instance variable. An instance
variable is any variable declared in the structure following the
@interface declaration of a class, and "static" is not a legal storage
qualifier in that context.
For example, this is illegal:
@interface EightBitLUT : NSObject
{
static unsigned char bytes[255];
}
...
If you're referring to static variables in .m files, they behave just
like any other static variables in C, and they're *not* ivars.
John:
Okay. It was a dumb question. I just went back and looked more closely
at the examples, and what I was thinking was a single variable is
actually two variables. One is a static variable, the other is an iVar.
The static variable is used to keep track of how many threads have been
created previously and the iVar value is assigned based on the value of
the static variable. Considering how long I stated at that code, I feel
pretty dumb.
Thanks for setting me straight. =)
Jeff