ObjectiveC - 键值对集合与重复的键 [英] ObjectiveC - Key-Value-Pair Collection with duplicate Keys
问题描述
ObjectiveC提供了键值对的集合,允许键多次出现?
Does ObjectiveC provide a collection for Key-Value-Pairs, that allow a key to occur multiple times?
我尝试将xml文件解析成一些简单的结构。每一件事都已经在使用嵌套的NSDictionary,但现在的xml元素可以多次出现。
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.
编辑:我的解决方案
我选择一个NSArray与KeyValuePairs,结果,我需要一个是秩序敏感,NSDictionary是不可能的。副作用:NSFastEnumeration很容易实现这种方式为我的集合。
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.
推荐答案
不,Cocoa没有这样的集合。如果你不想使用第三方库,你可以使用 NSDictionary
与 NSArray
值。或者,您可以查看 CHDataStructures 框架。
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.
这篇关于ObjectiveC - 键值对集合与重复的键的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!