• 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: Using NSDictionary in datasource
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Using NSDictionary in datasource


  • Subject: Re: Using NSDictionary in datasource
  • From: John Stiles <email@hidden>
  • Date: Wed, 14 Sep 2005 18:21:53 -0700

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:
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: This email sent to email@hidden
References: 
 >Using NSDictionary in datasource (From: James Gifford <email@hidden>)

  • Prev by Date: Bug? - Binding NSComboBox Enabled
  • Next by Date: Re: Disabling Display of JPG and PDF Files in NSTextView
  • Previous by thread: Using NSDictionary in datasource
  • Next by thread: Using Spotlight to watch for file change
  • Index(es):
    • Date
    • Thread