Re: NSDictionary allValues not mutable
Re: NSDictionary allValues not mutable
- Subject: Re: NSDictionary allValues not mutable
- From: Trygve Inda <email@hidden>
- Date: Sat, 09 Oct 2010 20:39:19 +0000
- Thread-topic: NSDictionary allValues not mutable
> Of course it is. Suppose for a minute that [myMutableDictionary allValues]
> returned a mutable array. That means that you could add to and remove from
> this array with impunity.
>
> Except... the objects in this array are supposed to have an associated key.
> If you remove an object from the array, then I suppose you could somehow get
> the dictionary to remove the key as well. But if you added an object to the
> array, what would its key be?
>
> That's why the array is immutable.
Ah. Thanks for this.
Ultimately I have a masterDict containing a few thousand dicts (all having
the same structure) which I need to convert to an array of dicts to be
displayed in an NSTable.
When I add to this array (quite rarely), I will actually add a new dict to
the masterDict and then append this same object to the array (managed by an
NSArrayController.
One of the items in each dict is the key that is used to place it in the
masterDict so when it is in the array I still know the key that refers to it
in the masterDict.
The reason for storing them as dicts in the masterDict instead of just an
array is that I really need to be able to find them on a key-by-key
basis.... The array is only for the ability to put them in an NSTable
w/NSArrayController.
Trygve
_______________________________________________
Cocoa-dev mailing list (email@hidden)
Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden