我有一系列字典,这些字典来自结果类型为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;来自NSArray的 endMonth = 3,9,12和 periodLength = 3,6,12?
谢谢!
答案 0 :(得分:2)
您可以使用valueForKey
:
NSArray *endCalYearArray = [resultArray valueForKey:@"endCalYear"];