objective c - NSPredicate expression to filter on count of a to-many relationship -
i have core data model one-to-many relationship e.g.:
@interface person : nsmanagedobect @property (nonatomic, retain) nsset *children; @end
i want create predicate gives me person
s have @ least 1 child:
i tried: [nspredicate predicatewithformat:@"person.children.count > 0"]
but nspredicate to-many key not allowed
.
ok, found documentation on realm.io site nspredicate
collection queries has answer:
you have use @count
instead of count
:
so: [nspredicate predicatewithformat:@"person.children.@count > 0"]
pity apple doesn't document (at least not find).
Comments
Post a Comment