Re: Simple newbie problem: Static variables in Objective-C?
Re: Simple newbie problem: Static variables in Objective-C?
- Subject: Re: Simple newbie problem: Static variables in Objective-C?
- From: Timothy Ritchey <email@hidden>
- Date: Fri, 22 Mar 2002 14:26:51 -0500
there are a couple places you can have a static variable in a function
implementation (scoped to only the function) or at file scope:
UniqueIDGenerator.m:
#import ...
static unsigned long long UIDG_msgID;
@implementation UniqueIDGenerator
+ (void)initialize
{
UIDG_msgID = 0xDEADBEEF; // etc.
....
}
@end
On Friday, March 22, 2002, at 01:36 PM, Andrew Baldwin wrote:
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.
_______________________________________________
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.