• 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
proper syntax for static variables in a class
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

proper syntax for static variables in a class


  • Subject: proper syntax for static variables in a class
  • From: Donald Hall <email@hidden>
  • Date: Sun, 9 Jun 2002 00:41:21 -0600

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.)

In MyClass.m I have:

#import "MyClass.h"

@implementation MyClass

static NSArray *mySharedData;

+(void)initialize
{
// fill in mySharedData here
}

Declaring mySharedData above '@implementation MyClass' works equally well.

Declaring mySharedData anywhere in the header file doesn't seem to work.

Is there a "correct" way to do this? A preferred style?

Thanks,

Don

----------------------------------------------
Donald S. Hall, Ph.D.
Apps & More Software Design, Inc.
http://www.theboss.net/appsmore
_______________________________________________
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: proper syntax for static variables in a class
      • From: "John C. Randolph" <email@hidden>
  • Prev by Date: Re: Toolbar and window resizing
  • Next by Date: OpenGL and NSOpenGLView troubles
  • Previous by thread: help with html to submenu display and....
  • Next by thread: Re: proper syntax for static variables in a class
  • Index(es):
    • Date
    • Thread