在iOS中使用多个键统计字典

在iOS中使用多个键统计字典,ios,count,nsdictionary,Ios,Count,Nsdictionary,这是我的JSON: collections = { items = ( { nom = "automne-hiver-2012-2013"; }, { nom = carbon; }, {

这是我的JSON:

collections =     {
        items =         (
                        {
                nom = "automne-hiver-2012-2013";
            },
                        {
                nom = carbon;
            },
                        {
                nom = colors;
            });
    };
}
我可以这样访问我的json:

int j=0;
NSString *collections=self.dictionaryMenu[@"collections"][@"items"][j][@"nom"];
我正在寻找我的JSON中的所有键名。 我尝试:

不幸的是,它向我发送了1个,我想这是因为JSON中只有1个集合

如何计算所有的键名?

试试这个:

NSArray *items = self.dictionaryMenu[@"collections"][@"items"];
NSUInteger count = 0;
for (NSDictionary *item in items) {
    if (item[@"nom"]) {
        count++;
    }
}

您的意思是nom为非零的所有项目的计数吗?是的,我想要nom为非零的所有项目的计数。
NSArray *items = self.dictionaryMenu[@"collections"][@"items"];
NSUInteger count = 0;
for (NSDictionary *item in items) {
    if (item[@"nom"]) {
        count++;
    }
}