0

我有一个字典数组,这些字典来自核心数据获取请求,结果类型为NSDictionary

request.resultType = NSDictionaryResultType;
request.returnsDistinctResults = YES;
request.propertiesToFetch = @[@"endCalYear",@"endMonth",@"periodLength"];

样例结果NSArray如下NSDictionary

{
    endCalYear = 2007;
    endMonth = 12;
    periodLength = 12;
},
{
    endCalYear = 2006;
    endMonth = 9;
    periodLength = 3;
},
{
    endCalYear = 2006;
    endMonth = 6;
    periodLength = 3;
},
{
    endCalYear = 2006;
    endMonth = 3;
    periodLength = 3;
}

创建(三个)单独数组的最有效方法是什么endCalYear = 2006, 2007, 2008; endMonth = 3, 9, 12 和periodLength = 3, 6, 12 来自给定的 NSArray?

谢谢!

4

1 回答 1

2

您可以使用valueForKey

NSArray *endCalYearArray = [resultArray valueForKey:@"endCalYear"];
于 2012-10-18T12:01:45.667 回答