• 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
[RESOLVED] Core Data request predicates and to-many relationships
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[RESOLVED] Core Data request predicates and to-many relationships


  • Subject: [RESOLVED] Core Data request predicates and to-many relationships
  • From: Luke Evans <email@hidden>
  • Date: Mon, 8 Dec 2008 17:05:44 -0800

OK, thanks again for the tips; SUBQUERY works fine. I'm actually querying for a collection of attribute matches, which translates to a range of SUBQUERYs in a compound predicate.

Of course, when you drill into the docs on NSExpression, there's some pretty nice discussion on SUBQUERY, but it might be nice to lift some of this material to the Predicate Programming Guide at some point - it had been a while since I dabbed in Core Data queries, and I had forgotten that there's a lot more than meets the eye in the Guide (last time around I had discovered the power of the 10.5+ function expression which is also pretty much a no-show in the Guide).

Another option is to invert the query: fetch all the destination objects which meet your criteria for the destination, set the request to prefetch the relationship you're actually interested in, then do a second fetch with (targetObjects IN resultsOfFirstFetch.toMany.@distinctUnionOfSets) and includesPropertyValues set to NO (the data is already in the row cache at this point).


Yes, I had tried an inverted query approach, but dealing with the distinct unions seemed decidedly awkward to code, particularly given the fact that I'm testing for the presence of multiple matching attributes per projected object.

Anyway, I'm back on the right side of the tracks with Core Data, and can start enjoying it again :-)

-- lwe


_______________________________________________

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


  • Follow-Ups:
    • Re: [RESOLVED] Core Data request predicates and to-many relationships
      • From: "Kyle Sluder" <email@hidden>
References: 
 >Core Data request predicates and to-many relationships (From: Luke Evans <email@hidden>)
 >Re: Core Data request predicates and to-many relationships (From: "Melissa J. Turner" <email@hidden>)
 >Re: Core Data request predicates and to-many relationships (From: Luke Evans <email@hidden>)
 >Re: Core Data request predicates and to-many relationships (From: "Melissa J. Turner" <email@hidden>)

  • Prev by Date: Re: building a custom NSView with IB?
  • Next by Date: Understanding text cell editing behaviour
  • Previous by thread: Re: Core Data request predicates and to-many relationships
  • Next by thread: Re: [RESOLVED] Core Data request predicates and to-many relationships
  • Index(es):
    • Date
    • Thread