Re: Best way to display dictionary in a table
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