NONE or NOT ANY in Core Data predicates
NONE or NOT ANY in Core Data predicates
- Subject: NONE or NOT ANY in Core Data predicates
- From: "David Wilson" <email@hidden>
- Date: Mon, 1 Oct 2007 23:55:01 -0400
For the purposes of this issue, I have two entities, Foo and Bar. Foo
has a to-many relationship to Bar, called bars.
My ultimate goal is to fetch those Foo objects that have certain
properties, and which do *not* contain relationships to Bar objects
that also have certain properties. The natural fetch request might be:
[NSPredicate predicateWithFormat:@"(name like %@) AND NONE ((bars.x ==
%d) AND (bars.name like %@))",fooName,barsX,barsName];
The Predicate Programming Guide (assuming I've read it correctly)
appears to back up the use of NONE in core data predicates. However,
testing seems to indicate that while ANY and ALL appear to work, NONE
does not- nor does NOT in combination with ANY or ALL. The above
predicate, and simpler tests with NOT ANY, NOT ALL, and NONE all fail
with NSPredicate complaining that it cannot parse the format string.
I've managed to work around this issue for now by fetching many more
objects than I actually need and doing the tests on the resulting
array. However, I imagine that if I could get the desired predicate to
work, I'd get much better performance out of leveraging Core Data to
do the filtering.
Am I simply missing something trivial here? Is NONE/NOT ANY not
actually working (either I'm misreading the documentation or it is
incorrect)? Or should I be approaching this problem from some other
angle?
--
- David T. Wilson
Princeton Satellite Systems
email@hidden
_______________________________________________
Cocoa-dev mailing list (email@hidden)
Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden