Re: static class variable
Re: static class variable
- Subject: Re: static class variable
- From: Ondra Cada <email@hidden>
- Date: Thu, 18 Jul 2002 15:04:31 +0200
On Thursday, July 18, 2002, at 07:57 , Hok Chun So wrote:
Do you know how to declare static class variables? I put the following
lines in the class definition.
@interface SyncFilter : NSObject {
static NSString *str1 = nil;
static NSString *str2 = nil;
}
However, the compiler complains:
SyncFilter.h:13: parse error before `static'
What's wrong with my declaration?
Well, that you did not read ObjC documentation.
There are no class variables in ObjC at all (but, so far as your example
goes, I think you had instance variables in mind).
I can create static variable using the above syntax in function.
And the static variables it has are those of plain C, with exactly the
plain C syntax and semantics.
I guess you wanted just this:
@implementation SyncFilter
static NSString *str1=nil,*str2=nil;
...
@end
In case you wanted _true_ class variables, you have to use an NSDictionary
keyed by class ID or name. But I guess that is not the case -- the need
for true class variables is pretty rare.
---
Ondra Cada
OCSoftware: email@hidden
http://www.ocs.cz
private email@hidden
http://www.ocs.cz/oc
_______________________________________________
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.