Re: proper syntax for static variables in a class
Re: proper syntax for static variables in a class
- Subject: Re: proper syntax for static variables in a class
- From: Matt Neuburg <email@hidden>
- Date: Mon, 10 Jun 2002 09:10:40 -0700
On Sun, 9 Jun 2002 00:41:21 -0600, Donald Hall <email@hidden> said:
>
I have an object that I want to be shared by all instances of a class.
>
Currently I have the following structure, but I wonder if this is
>
correct. (It seems to compile and run okay, but I could find nothings in
>
the docs.)
You could find nothing the docs chiefly because this isn't an Objective-C
matter. Scoping of variables is as in C. You might want to read an
elementary C textbook - Kernighan and Ritchie is still the best.
Also, see the examples in ClassClusters.html and in NSObject.html (under
+initialize).
>
#import "MyClass.h"
>
@implementation MyClass
>
static NSArray *mySharedData;
>
+(void)initialize
>
{
>
// fill in mySharedData here
>
}
>
Is there a "correct" way to do this? A preferred style?
What you're doing isn't bad, but I think the examples I've pointed to above
will give you some more to think about. m.
--
matt neuburg, phd = email@hidden,
http://www.tidbits.com/matt
pantes gar anthropoi tou eidenai oregontai phusei
Subscribe to TidBITS! It's free and smart.
http://www.tidbits.com/
_______________________________________________
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.