RE: NSDictionary allValues not mutable
RE: NSDictionary allValues not mutable
- Subject: RE: NSDictionary allValues not mutable
- From: Jeff Laing <email@hidden>
- Date: Sun, 10 Oct 2010 23:14:55 +0000
- Acceptlanguage: en-US
- 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.
Um, no they aren't. Arrays don't have "keys".
What you are returned is an arbitrary array that was initially populated with all the objects in the dictionary. There is no implied linkage back to the dictionary.
Adding another object to the dictionary is not going to make a new object appear in the array; why should adding an object in the array make it appear in the dictionary?
(Note, adding an object to the dictionary might make the *property* allValues return something different, but that's a different topic)
_______________________________________________
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