• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
How to write predicate to filter for to-many relationship
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

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


  • Prev by Date: Re: Creating QTMovie with multiple tracks just for playing them
  • Next by Date: Re: dumb NSLog question
  • Previous by thread: Re: Accessing the Preference setup of other application
  • Next by thread: Managing selectedObjects
  • Index(es):
    • Date
    • Thread