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 persons 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

Popular posts from this blog

javascript - AngularJS custom datepicker directive -

javascript - jQuery date picker - Disable dates after the selection from the first date picker -