• 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
Newbie question - is where Obj-C analog for a C++ static data members?
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Newbie question - is where Obj-C analog for a C++ static data members?


  • Subject: Newbie question - is where Obj-C analog for a C++ static data members?
  • From: Rustam Muginov <email@hidden>
  • Date: Wed, 10 Sep 2003 11:23:17 +0400

Hello all.
I have a document-based applications, with several windows where different
objects are drawn.
I need to draw them with the different colors, depending on the object
"type" or "kind".
So I created the NSDictionary, with the colors as objects and object types
as the keys.

The questions is - how could I optimize my code and not the build such
colors dictionary for every WindowController (or for every document)?
In C++, I could declare the static data member for the class, init it with
NULL value, and then check it from the instance method, building the color
list if its not already build.
In Cocoa, I could probably define the "standalone" global variable and use
it for the same purposes, but I feel this is not very "cocoa-ish"

How should I implement "shared" object, which will be inited once and then
used by many instances?
_______________________________________________
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: Newbie question - is where Obj-C analog for a C++ static data members?
      • From: Neil Earnshaw <email@hidden>
  • Prev by Date: Re: Multiple Windows and Cocoa
  • Next by Date: Re: How do I convert data in NSString to NSImage
  • Previous by thread: Re: How do I convert data in NSString to NSImage
  • Next by thread: Re: Newbie question - is where Obj-C analog for a C++ static data members?
  • Index(es):
    • Date
    • Thread