Re: Core Data Predicate Question

2011-07-08 Thread Indragie Karunaratne
Awesome, thank you. For anyone else who stumbles upon this question looking for something similar, check out Apple's DerivedProperty example: http://developer.apple.com/library/mac/#samplecode/DerivedProperty/Introduction/Intro.html It has examples on using the <= & > string comparison trick as

Re: Core Data Predicate Question

2011-07-08 Thread The Karl Adam
Well, when I said ANY, I really meant "IN termsArray", but for the partial matches that you want your approach is fine, you'll just want to use > & <= with character evaluations to speed this up. Check the 2010 CoreData Performance session from WWDC for more details, but it's a standard SQL trick t

Re: Core Data Predicate Question

2011-07-08 Thread Jerry Krinock
On 2011 Jul 07, at 10:38, Indragie Karunaratne wrote: > I'm sure there's a better way to simplify this instead of using a giant > compound AND predicate On the contrary, I don't trust that predicateWithFormat: stuff. It's too easy to type mistakes into the format string; in particular it temp

Re: Core Data Predicate Question

2011-07-07 Thread Indragie Karunaratne
I came up with this code earlier: NSArray *searchTerms = [cleanedQuery componentsSeparatedByString:@" "]; NSPredicate *basePredicate = [NSPredicate predicateWithFormat:@"SUBQUERY(keywords, $keyword, $keyword.name BEGINSWITH $QUERY).@count != 0"]; NSMutableArray *subpredicates = [NSMutabl

Core Data Predicate Question

2011-07-06 Thread Indragie Karunaratne
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".