• 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: Is it 'wrong' to use a global dictionary?
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Is it 'wrong' to use a global dictionary?


  • Subject: Re: Is it 'wrong' to use a global dictionary?
  • From: Jonathan Hendry <email@hidden>
  • Date: Wed, 12 Mar 2003 07:56:20 -0500

On Wednesday, Mar 12, 2003, at 07:07 America/New_York, Jason Galarneau wrote:

I'm making an app that stores its data (1000's of instances of a custom object) in a dictionary, and would like to be able to access that data from any bit of my program (i.e. from within the code of any of my controlling objects)

Is it bad form to use a global dictionary for such a purpose? What is the 'established' way to do such a thing in Cocoa?

You could put it inside a 'singleton' class.

Then anywhere in your program that you want access to the dictionary, get
it through the class. Model it on the panels provided by the system
such as the Font panel.

If you wrap it in a class called "DictionaryWrapper",
you could access it as:

DictionaryWrapper *myWrapper = [DictionaryWrapper sharedDictionary];
NSDictionary *dictionary = [myWrapper dictionary];

Something along those lines, anyway. Someone else can probably
suggest a better or more elegant way of going about it.
_______________________________________________
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: 
 >Is it 'wrong' to use a global dictionary? (From: Jason Galarneau <email@hidden>)

  • Prev by Date: NSMenu and menu handle
  • Next by Date: Help with crash
  • Previous by thread: why are custom menus killed? (Re: NSMenu and menu handle)
  • Next by thread: NSSlider in an NSToolbar problems
  • Index(es):
    • Date
    • Thread