• 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
Re: Class variable?
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Class variable?


  • Subject: Re: Class variable?
  • From: Glen Low <email@hidden>
  • Date: Sat, 7 Feb 2004 07:20:01 +0800

Is there a way in Cocoa to define a class variable that is shared among all instances of that class, analogous to a +method? How?


You could try declaring a global static variable within your .m file (not the .h header). Since it's static, it won't get seen by any other .m file, only the code within the declaring .m file. The variable is effectively shared among all instances

e.g.

static int shared = 0;

+ (int) incrementShared
{
return ++shared;
}

Cheers, Glen Low


---
pixelglow software | simply brilliant stuff
www.pixelglow.com
_______________________________________________
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.

References: 
 >Class variable? (From: Randall Meadows <email@hidden>)

  • Prev by Date: Re: malloc in obj-c/cocoa
  • Next by Date: Re: malloc in obj-c/cocoa
  • Previous by thread: Re: Class variable?
  • Next by thread: Question about "JPEG writer requires compacted components"
  • Index(es):
    • Date
    • Thread