Setup:
I have a Core Data object A that has a to-many relation to B. Call the relation \"items\". So, a.items returns all B-s associated with A.
Now, I have
The following predicate could work:
[NSPredicate predicateWithFormat:@"(items.@count == %d) AND (SUBQUERY(items, $x, $x IN %@).@count == %d)",
itemSet.count, itemSet, itemSet.count];
The predicate checks first that the number of items is equal to the size of the given itemSet
, and then checks that the number of items which are member of itemSet
is also equal to the size of itemSet
. If both are true, then items
must be equal to itemSet
.
Have you tried:
NSPredicate *predicate = [NSPredicate predicateWithFormate:@"items == %@", itemSet];
Alternatively, pull out a subset with a simpler predicate and filter them outside of the fetch request. i.e.