Skip navigation.
 
mlHas anyone put together an order-preserving NSDictionary
FROM : Scott Ellsworth
DATE : Thu Apr 14 21:36:50 2005

Hi, all.

I have an NSDictionary as one of my primary datastores.  I want to 
throw its contents into an NSTableView via the NSArrayController 
running the table.

Currently, I do this the ugly way: take the dictionary, grab the key 
array, copy it, then use that read-only stable copy to rummage 
through.  (Done because the ordering can potentially change on you.)

I would much rather have something with both NSDictionary and NSArray 
accessors that exposes the underlying key array in a stable order, so 
add and delete work correctly and are reflected in the underlying 
data.  This would involve a subclass that composes an 
NSMutableDictionary and NSMutableArray, and which then overrides 
appropriate methods and passes them through to the underlying data 
stores.

Not terribly difficult conceptually, but enough of a pain to do right 
that I do not relish it.  Anyone already done this and put it Out There?

Scott

Related mailsAuthorDate
No related mails found.