Simple newbie problem: Static variables in Objective-C?
Simple newbie problem: Static variables in Objective-C?
- Subject: Simple newbie problem: Static variables in Objective-C?
- From: Andrew Baldwin <email@hidden>
- Date: Fri, 22 Mar 2002 13:36:32 -0500
I know that it is possible to have static class variables in
Objective-C, but I have searched the documentation for the last hour and
tried multiple ways of declaring a static variable and none has
satisfied the compiler. All I want is something like the following:
@interface UniqueIDGenerator : NSObject
{
static unsigned long long msgID;
}
@end
In + (void)initialize I would then set msgID to 0. How do I declare
msgID? I can't build because I get "Parse error before static".
I know I should have been able to solve this easily on my own, but I
read the Objective-C reference in the developer documentation and even
when I basically copied the example code (using NSNumber* instead of
Sibling*) I couldn't get it to compile and would keep getting a parse
error at static, or when I tried to use the static NSNumber* (created in
initialize) I would get a compile error that it was undeclared.
Thanks for any help,
Andrew
_______________________________________________
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.