Reputation: 17
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"
Upvotes: 0
Views: 515
Reputation: 215
Use "self"in your code to get the array element's valueForKeyPath
NSPredicate *objIdPredicate =[NSPredicate predicateWithFormat:@"(self.objectId = %@)",obj];
`
Upvotes: 2