Using NSPredicate to filter on both Core attribute and entity
Posted
by
Ben Thompson
on Stack Overflow
See other posts from Stack Overflow
or by Ben Thompson
Published on 2012-04-14T05:14:38Z
Indexed on
2012/04/14
5:28 UTC
Read the original article
Hit count: 232
I have two entities in core data (call them entityOne and entityTwo). I have a entityOne<--->>entityTwo relationship between them.
I am now trying to code an NSPredicate to fetch entityTwo objects on the following basis:
Fetch entityTwo objects that have a relationship with a specified entityOne object.
Filter out those entityTwo objects which have no value for one of their attributes.
I am best doing both of these in an NSPredicate or is there a better way?
I am trying the following:
NSPredicate *predicate = [NSPredicate predicateWithFormat:@"(attribute <> "") AND (relationship == entityOne"];
[request setPredicate:predicate];
Any pointers on coding great fully received.
© Stack Overflow or respective owner