Core Data request predicates and to-many relationships
Core Data request predicates and to-many relationships
- Subject: Core Data request predicates and to-many relationships
- From: Luke Evans <email@hidden>
- Date: Sat, 6 Dec 2008 01:45:55 -0800
If there are any NSPredicate gurus out there, I'm scratching my head
on this one:
I have an entity that can optionally have a set of attributes (name-
value pairs). This is set up in the model as a optional to-many
relationship to an attribute entity.
Now, I want to fetch the list of managed objects of this entity whose
attributes exactly match a dictionary that is passed. The predicate
for this needs to filter the objects that have all the required
attributes; matching both the name, and value for each attribute.
At this point I'm not seeing how you can code this in a predicate. If
I AND some clauses like:
...ANY attr.name == %@ AND ANY attr.value == %@...
for each attribute I'm testing for, then AFAICS I'm not testing that
the _same_ attr has the name and value.
I wondered about:
...ANY (attr.name == %@ AND attr.value == %@)...
but this doesn't appear to be legal syntax.
I'm still experimenting, but if anyone knows how to express a query
that allows multiple clauses on the _same_ entity across a to-many
relationship I'd appreciate a clue!
Cheers
Luke
_______________________________________________
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