Reputation: 5634
I have an array of dictionaries which results from an Core Data fetch request with results type of NSDictionary
:
request.resultType = NSDictionaryResultType;
request.returnsDistinctResults = YES;
request.propertiesToFetch = @[@"endCalYear",@"endMonth",@"periodLength"];
A sample result NSArray
of NSDictionary
looks as follows:
{
endCalYear = 2007;
endMonth = 12;
periodLength = 12;
},
{
endCalYear = 2006;
endMonth = 9;
periodLength = 3;
},
{
endCalYear = 2006;
endMonth = 6;
periodLength = 3;
},
{
endCalYear = 2006;
endMonth = 3;
periodLength = 3;
}
What would be the most efficient way to create (three) separate arrays endCalYear = 2006, 2007, 2008; endMonth = 3, 9, 12 and periodLength = 3, 6, 12 from the NSArray given?
Thank you!
Upvotes: 0
Views: 201
Reputation: 539685
You can use valueForKey
:
NSArray *endCalYearArray = [resultArray valueForKey:@"endCalYear"];
Upvotes: 2