Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

ObjectiveC - Key-Value-Pair Collection with duplicate Keys

Does ObjectiveC provide a collection for Key-Value-Pairs, that allow a key to occur multiple times?

I try to parse a xml file into some simple structure. Every things is already working with nested NSDictionary, but now xml elements can occur multiple times.

Edit: My Solution

I choose an NSArray with KeyValuePairs, it turned out that I need something that is order sensitive, NSDictionary was not possible. Sideeffect: NSFastEnumeration is easy to implement this way for my collection.

like image 533
Fox32 Avatar asked Feb 24 '23 22:02

Fox32


1 Answers

No, Cocoa doesn’t have such a collection. If you don’t want to use a third-party library for that you can simulate that by using a NSDictionary with NSArray values. Or you could take a look at the CHDataStructures framework.

like image 181
Sven Avatar answered Mar 02 '23 16:03

Sven