• 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: [Newbie] Good NSDictionary example?
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [Newbie] Good NSDictionary example?


  • Subject: Re: [Newbie] Good NSDictionary example?
  • From: Andreas Mayer <email@hidden>
  • Date: Sun, 8 Sep 2002 01:05:22 +0200

Am Sonntag, 08.09.02 um 00:11 Uhr schrieb Keith Pritchard:

Want to be able to say, for myreference="something" show me name, subject,date ... the results of which end up in a table.

Looks like a dictionary of objects to me.

Build a class with name, subject and date properties and, create an object for each dataset and put it in a dictionary with <something> as key.

To create an empty mutable dictionary use

myDictionary = [NSMutableDictionary dictionaryWithCapacity:35000];

(While you may adjust the initial capacity for greater speed, the dictionary will grow automatically if needed.)

Then create your records and add them like this:

[myDictionary setObject:anObject forKey:aKey];


Caveats:

- NSMutableDictionary dictionaryWithCapacity: returns an autoreleased dictionary. So you have to retain it, to keep it around
- if you don't not need your datasets to perform any actions, you may use a dictionaries or arrays instead of your own class to hold the data
- I'm not sure how the performance of NSDictionary is with many entries


bye. Andreas.
_______________________________________________
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] Good NSDictionary example?
      • From: Ondra Cada <email@hidden>
References: 
 >[Newbie] Good NSDictionary example? (From: Keith Pritchard <email@hidden>)

  • Prev by Date: Re: [Newbie] Good NSDictionary example?
  • Next by Date: NEWBIE: NSArray toll-free-bridged with CFArray?
  • Previous by thread: Re: [Newbie] Good NSDictionary example?
  • Next by thread: Re: [Newbie] Good NSDictionary example?
  • Index(es):
    • Date
    • Thread