Is their a Cocoa container class that functions like the standard template library's multimap, i.e. letting you have multiple values for an identical key? I've been trying to sift through the Cocoa documentation, but no such luck, maybe I'm just retarded?
+1
A:
Nope.
The easiest way to get that behaviour would be to use a dictionary whose values are NSSet
s, NSCountedSet
s or NSArray
s.
Ahruman
2009-01-23 07:43:56
+6
A:
Your options:
Use NSMutableSet, NSCountedSet or NSMutableArray instances as dictionary values. This works fairly conveniently, but does have the downside of exposing your data structure's mutability to all in contact with it.
Write your own; either as a subclass of NSMutableDictionary, or NSObject.
Use an existing solution such as OFMultiValueDictionary from the OmniGroup.
Mike Abdullah
2009-01-23 10:56:32