Re: [Newbie] Good NSDictionary example?
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.