I have Array of format as below
[
   {
      "xyz" : [Array with different values];
      ... many more keys            
   },
   {
     .. same as above dictionary
   }
   ... many more dictionaries
]
Here see, i have Main Array of dictionaries, where each dictionary have different keys, in which there is "xyz" key, whose value is again an Array. Now i want those dictionaries for which, xyz's array must have count>2.
Now i have tried with following predicate:
NSPredicate *predicate = [NSPredicate predicateWithFormat:@"xyz.count>2"];
NSArray *filteredArray = [resultArray filteredArrayUsingPredicate:predicate];
but this is giving me error something like this, xyz is not key-value complaint for key "count"
In this case that results in -valueForKey: @"count" being sent to each xyz instance, and xyz  isn't key value coding compliant for count.
Instead, use the @count operator to evaluate the count of the collection when you want the count then use
 NSPredicate *predicate = [NSPredicate predicateWithFormat:@"xyz.@count>2"];
instead of
NSPredicate *predicate = [NSPredicate predicateWithFormat:@"xyz.count>2"];
                        If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With