Mailing Lists: Apple Mailing Lists

Image of Mac OS face in stamp
 
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Using NSDictionary in datasource



I could be mistaken, but dictionaries tend to be a bad fit with table data sources because there's no constant-time way, given an "index" value, to find an item in the dictionary. Plus, since the item ordering in a dictionary is arbitrary, the order of items in the table would be random from an end-user perspective (and, in theory, it could could completely rearrange itself any time you added or removed entries).


On Sep 14, 2005, at 3:08 PM, James Gifford wrote:

Hi all,

I've got a question concerning NSDictionaries and datasources.

I understand using an NSArray to hold a list of objects to populate an NSTableView. However, I've got some data that I am currently storing in an NSDictionary that I would like to use in my datasource. My question is: should I use an NSDictionary or an array of NSDictionaries, or an array of arrays?

My data is rather simple: I've got a bunch of NSStrings and for each one there is an NSNumber indicating how often the string appears in another datasource. So, for instance, I might have the pair "Bob" and 3. Currently I am using the string as the key and the number as the value for each entry in the dictionary. The problem is, I can't figure out how to properly implement the datasource methods using a dictionary. The - tableView:objectValueForTableColumn:row method looks for data based on the index of the row, but how can I look up data in an unordered dictionary based on an index value? I am just looking for the most efficient way to store my data for use in the datasource.

Any help at all would be much appreciated. _______________________________________________
Do not post admin requests to the list. They will be ignored.
Cocoa-dev mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/cocoa-dev/jstiles% 40blizzard.com


This email sent to email@hidden


_______________________________________________ Do not post admin requests to the list. They will be ignored. Cocoa-dev mailing list (email@hidden) Help/Unsubscribe/Update your Subscription: http://lists.apple.com/mailman/options/cocoa-dev/email@hidden

This email sent to email@hidden
References: 
 >Using NSDictionary in datasource (From: James Gifford <email@hidden>)



Visit the Apple Store online or at retail locations.
1-800-MY-APPLE

Contact Apple | Terms of Use | Privacy Policy

Copyright © 2007 Apple Inc. All rights reserved.