The solution to your problem is to use the @count operator, as in @" parents.@count == 0" .
Reading the exception, we see that the predicate evaluation sent a -count message to the -count object. Why?
Sending -valueForKey: to the collection (in your case, the collection is an NSSet, which was the result of evaluating the parents component of the key path) sends -valueForKey: each object in the collection.
In this case, this causes -valueForKey: @"count" sent to each GTPerson instance, and GTPerson is not an encoding of key values ββfor counting.
Instead, use the @count operator to calculate the count of the collection when you want the count of the collection, not the value of the count key, for all objects in the collection.
source share