How to write predicate to filter for to-many relationship
How to write predicate to filter for to-many relationship
- Subject: How to write predicate to filter for to-many relationship
- From: Kay Roepke <email@hidden>
- Date: Mon, 9 Jan 2006 11:44:06 +0100
Hi!
I have set up a CoreData model with two entities Chord and String.
Chord has a to-many relationship 'strings' with the String entity, I
also have a to-one inverse
relationship. Each Chord has exactly six Strings, although that will
change later on (think 4, 5 or 12 string
instruments).
What I want to do is to filter the chord objects according to their
strings' properties.
String has properties like stringNumber and isPlayed. It actually has
more, but those two are representative
for my problem.
I can write a predicate for either with no problems: "ANY
strings.isPlayed == 1" gives me all chords where
any string is played at all. "ALL strings.isPlayed" yields
(obviously) those chords for which all strings are
played simultaneously. Now I want to filter all chords whose E-string
(stringNumber == 0) are played.
I cannot get that to work. I've read all the relevant CoreData,
Predicates and Bindings docs and have searched
the archives but cannot find any hint as to the solution.
Predicates like "ANY strings.isPlayed == 1 and ANY
strings.stringNumber == 0" are not doing the right thing (well,
to be honest, not the thing I want ;) Possibly I could create a
String object and pass it into the predicate as an
argument (like "ANY strings == $string" with string being an
appropriately set up String object), but I'd rather not do that,
for it seems a bit unnatural.
I noticed the SUBQUERY reserved word in the Predicates docs, but
could find any information on its use, or whether it's
supported at all.
Thanks,
Kay
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Cocoa-dev mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden