• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Simple newbie problem: Static variables in Objective-C?
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

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.

  • Follow-Ups:
    • Re: Simple newbie problem: Static variables in Objective-C?
      • From: Marcel Weiher <email@hidden>
    • Re: Simple newbie problem: Static variables in Objective-C?
      • From: "David W. Halliday" <email@hidden>
    • Re: Simple newbie problem: Static variables in Objective-C?
      • From: Timothy Ritchey <email@hidden>
    • Re: Simple newbie problem: Static variables in Objective-C?
      • From: Kurt Revis <email@hidden>
    • Re: Simple newbie problem: Static variables in Objective-C?
      • From: Andy Lee <email@hidden>
  • Prev by Date: Re: An other silly PrefPane problem
  • Next by Date: Re: Does NSSound not work in a Unix tool? - SOLUTION
  • Previous by thread: Irish developer group?
  • Next by thread: Re: Simple newbie problem: Static variables in Objective-C?
  • Index(es):
    • Date
    • Thread