0

I have an array where the 'id' on which i want to filter the array exists at valueForKeyPath 'objectId' of each of its dictionaries. How to compare the predicates in ValueForKeyPath.

Currently.. this predicate

NSPredicate * objIdPredicate = [NSPredicate predicateWithFormat:@"objectId = %@",obj];
NSArray * oneOrder = [array filteredArrayUsingPredicate:objIdPredicate];

is considering key and values of the array elements, not the ones at their ValueForKeyPath=@"objectId"

Sanjay Mohnani
  • 5,947
  • 30
  • 46

1 Answers1

2

Use "self"in your code to get the array element's valueForKeyPath

NSPredicate *objIdPredicate =[NSPredicate predicateWithFormat:@"(self.objectId = %@)",obj];

`

UIBittu
  • 215
  • 2
  • 13