• 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
Re: Need some help with fetch requests
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Need some help with fetch requests


  • Subject: Re: Need some help with fetch requests
  • From: "Carter R. Harrison" <email@hidden>
  • Date: Fri, 1 Feb 2008 15:41:05 -0500


On Feb 1, 2008, at 3:36 PM, Chris Hanson wrote:

On Feb 1, 2008, at 12:03 PM, Carter R. Harrison wrote:

Today I'm working with NSFetchRequests for the first time and I need some help learning how to filter down the initial set of managed objects that I want to search against.

Entity: File
Relationship: Messages

I assume you actually mean "messages" given that properties of objects in Objective-C start with lower-case letters. :)

You assumed correctly. Thanks for making a note of this though.



My initial thought was to add more criteria to my predicate to help narrow down the search base, but I'm not sure how the predicate's criteria could traverse relationships.

Magic. :)

Do all of your relationships have appropriate inverses? If not, they should. Then you could just use a predicate like this:

NSPredicate *fieldSearchPredicate = [NSPredicate predicateWithFormat:
@"(message.file IN %@) AND (value = %@)", files, requestedFieldValue];


Use that in a fetch request on the Field entity and it should just work. "files" should be an NSArray or NSSet of instances of your File entity, or NSManagedObjectID instances representing instances of your File entity.


Excellent! I had already made inverse relationship so your answer should work. I'm not sure why I couldn't figure that out, but I do appreciate it!


 -- Chris


_______________________________________________

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


References: 
 >Need some help with fetch requests (From: "Carter R. Harrison" <email@hidden>)
 >Re: Need some help with fetch requests (From: Chris Hanson <email@hidden>)

  • Prev by Date: Re: memory management issue?
  • Next by Date: Re: What paradigm behind NSColor's drawing methods?
  • Previous by thread: Re: Need some help with fetch requests
  • Next by thread: Setting to not open document at startup?
  • Index(es):
    • Date
    • Thread