Filter NSArray from NSDictionary with specific key value

I have an NSArray NSDictionary that looks like this.

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

      

How can I filter out all the 'b' key values ​​that will eventually return me an NSArray like this,

('two','eleven')

      

Is it possible to do this simply by using NSPredicate without having a loop?

+3


source to share


1 answer


You can do this with a single method in NSArray:



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

      

+10


source







All Articles