ObjectiveC - a collection of core values ​​with duplicate keys

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

I am trying to parse an XML file in some simple structure. All things already work with nested NSDictionary, but now xml elements can occur several times.

Edit: My solution

I choose NSArray with KeyValuePairs, it turned out that I needed something order sensitive, NSDictionary failed. Sideeffect: NSFastEnumeration is easily implemented this way for my collection.

+4
source share
3 answers

No, Cocoa does not have such a collection. If you do not want to use a third-party library for this, you can mimic this using NSDictionary values ​​with NSArray . Or you can take a look at the CHDataStructures framework.

+4
source

That would not be a very good key ....

It is best to have an NSDictionary, and for each NSArray key, hold all values ​​against that key.

+3
source

Or an NSArray containing as many NSDictionaries (or NSObjects with a key and value) as you like. Then you can filter the array using the predicate to find all occurrences of a particular key and its associated values.

+1
source

All Articles