从NSArray获取值并将其添加到NSDictionary

时间:2012-07-26 11:50:00

标签: ipad nsarray nsdictionary

我在数组中有NSArray我有很多字典。我希望所有这些字典值都成为单个字典

jewels array (
    {
    headAccObi = "<AccessoriesObject: 0x7f7da00>";
},
    {
    headAccObi = "<AccessoriesObject: 0x7f7da00>";
    noseAccObj = "<AccessoriesObject: 0x7f84e40>";
},
    {
    headAccObi = "<AccessoriesObject: 0x7f7da00>";
    neckAccObj = "<AccessoriesObject: 0x7f7d8c0>";
    noseAccObj = "<AccessoriesObject: 0x7f84e40>";
}

我想要这样的输出

    {
    headAccObi = "<AccessoriesObject: 0x7f7da00>";
    headAccObi = "<AccessoriesObject: 0x7f7da00>";
    noseAccObj = "<AccessoriesObject: 0x7f84e40>";
    headAccObi = "<AccessoriesObject: 0x7f7da00>";
    neckAccObj = "<AccessoriesObject: 0x7f7d8c0>";
    noseAccObj = "<AccessoriesObject: 0x7f84e40>";
}

我怎样才能做到这一点?

1 个答案:

答案 0 :(得分:0)

由于您使用了多次相同的密钥,因此无法精确创建您所描述的结构。如果密钥重复,则使用setObject:forKey:添加对象将替换现有对象。您需要在字典中为每个键存储一个对象数组,例如重复的headAccObi