如何在索引的帮助下不使用NSDictionary中的键来获取价值?

时间:2016-02-03 07:33:57

标签: ios nsarray nsdictionary

{
 id:1
 Vendors:
        {
          47:
             {
               items:{
                     }
               price:
                    {
                     this value I want
                    }
             }
          55:
            {
            }
  • 在上面的代码中,我不知道它在哪个索引处的供应商ID。所以我不能使用valueForKey。我可以获得两个ID的价格数组,如:

    arrayPrice:{              {               值1              }              {                值2              }            }

或者有没有办法获得索引的关键字。这样我就可以使用valueForKey:@“47”

1 个答案:

答案 0 :(得分:2)

您可以使用NSDictionary allValues的属性,但无法维护序列,因为NSDictionary根据键进行索引。如果订单对您很重要,则必须使用NSArray