Hi all,

I have a Core Data object model that I'm trying to write a fetch predicate for 
(to use for search). Quick explanation of the model:

We'll call the main entity "Book".  There's also a "Keyword" entity. The Book 
entity has a to-many relationship with the Keyword entity called "keywords". In 
turn, the Keyword entity has an inverse relationship with the Book entity 
called "book".  The Keyword entity has a single attribute called "name". So 
basically, each Book has Keywords that describe it.

For my search, I have an array of search terms. I need a predicate that I can 
use on fetch requests for the Book entity that will evaluate to TRUE if ALL of 
the search terms have a corresponding Keyword in that the "name" property 
begins with the search term.

For example:

There are three books:
Book1 - keywords: {"fiction", "scifi"}
Book2 - keywords: {"nonfiction"}

If the search terms were {"fic", "nonfic", "sci"} the resulting fetched array 
would contain NOTHING because none of the books have keywords that begin with 
all 3 of those search terms..

However, if the search terms were {"fic", "sci"}, the resulting fetched array 
would contain Book1 since its keywords "fiction" and "scifi" begin with the two 
search terms "fic" and "sci".  The key part here is that ALL of the search 
terms have to have a corresponding keyword as demonstrated above for the 
predicate to evaluate to true.

I hope I've explained this problem well enough, it's hard to put this stuff 
into words ;-)

Any help is appreciated,
Indragie_______________________________________________

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

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:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to arch...@mail-archive.com

Reply via email to