In article
<2008062407584675249-michaelhopkins@[EMAIL PROTECTED]
>,
Michael Hopkins <michael.hopkins@[EMAIL PROTECTED]
> wrote:
> On 2008-06-20 13:39:17 +0100, Gregory Weston <uce@[EMAIL PROTECTED]
> said:
>
> > In article <tu-dnQDAt7EO_cbVnZ2dnUVZ_oDinZ2d@[EMAIL PROTECTED]
>,
> > Don Bruder <dakidd@[EMAIL PROTECTED]
> wrote:
> >
> >> Well... Four days and nobody has shot it down... Does that mean I'm
safe
> >> in assuming that I got it right? :)
> >
> > Nope. It means I never saw the post. The variables g, h, k and l exist
> > at the level of the compilation unit - the file. You could confirm
that
> > by writing a function outside the class that uses them (which would
> > succeed), or by declaring a second class in the same file that tries
to
> > redeclare the variables (which would fail).
> >
> > The simplest way to achieve something like a class variable in Obj-C
is
> > to commit yourself to having a single class per implementation file
and
> > use static variables with file scope.
>
>
> Thanks for the input Gregory but I am still not sure if g, h, k & l are
> per _class_ (i.e. shared by all instances of that class) or per
> _object_ (i.e. each instance of the class has a separate version), and
> whether the static modifier has any effect on this behaviour.
>
> They are declared within the @[EMAIL PROTECTED]
for a class but not as
> instance variables and I have never seen this discussed anywhere.
It has been how many days?
Write a test program. run it. answer your own question here.
I think you'll find that statics declared in a .h file are neither per
class nor per instance, they are per file. That is, if you include a.h
in 1.m, 2.m, 3.m, they'll each get their own separate copy, a static
var, of any static variables declared in the .h.


|