• 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: Best way to display dictionary in a table
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Best way to display dictionary in a table


  • Subject: Re: Best way to display dictionary in a table
  • From: mmalcolm crawford <email@hidden>
  • Date: Thu, 18 Aug 2005 13:35:50 -0700


On Aug 18, 2005, at 1:20 PM, Andreas Mayer wrote:

What is the 'right' way to display the contents of a dictionary and allow users to edit the values (assuming they are strings)?
Build an array controller that accesses the dictionary, I would assume.
Then you will be able to bind the table columns to the array controller.

No, it's not this simple. You have to build in effect a dictionary to array transformer. You need a way to arrange the keys and values of the dictionary into an array that an array controller can then use. One approach is to create a KeyValue class that has two variables, (obviously) key and value, and to create instances of these for each key-value pair in the dictionary. You then create an array of all these instances to pass to the array controller. The difficulties come in various forms: you must ensure you keep a mapping between the KeyValue instances and the corresponding key- value pairs in the dictionary; you must ensure that if a user edits a key, or creates a new key, that it is not the same as an existing key; you must be prepared to deal with sorting (see first point); etc. It's not desperately complex, but it's not trivial either.


mmalc

_______________________________________________
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


  • Follow-Ups:
    • Re: Best way to display dictionary in a table
      • From: Rick Hoge <email@hidden>
References: 
 >Best way to display dictionary in a table (From: Rick Hoge <email@hidden>)
 >Re: Best way to display dictionary in a table (From: Andreas Mayer <email@hidden>)

  • Prev by Date: Re: Best way to display dictionary in a table
  • Next by Date: NSMovieView Audio clicks
  • Previous by thread: Re: Best way to display dictionary in a table
  • Next by thread: Re: Best way to display dictionary in a table
  • Index(es):
    • Date
    • Thread