Min Soe
Min Soe

Reputation: 1244

Filter NSArray of NSDictionary with specific key's value

I have a NSArray of NSDictionary which is like the following.

({
  a = 'one'
  b = 'two'
},
{
  a = 'ten'
  b = 'eleven'
})

How can I filter all values of key 'b' which will eventually return me a NSArray like this,

('two','eleven')

Can it be done with just using NSPredicate without having to loop?

Upvotes: 3

Views: 2129

Answers (1)

Vladimir
Vladimir

Reputation: 170839

You can do it with single method in NSArray:

NSArray *resultArray = [yourArray valueForKey:@"b"];

Upvotes: 10

Related Questions