I have asked this in the past but couldn’t get a clear answer.
I have an object in CoreData like this, KeyWord(word, chapter)
Word Chapter
cold chapter1
cold chapter2
cold chapter3
weather chapter1
weather chapter2
humidity chapter7
Florida chapter8
Florida chapter9
I would like the user to search for any of these words as in “cold Florida weather ..”
So, I broke the search into an NSArray *tokens = [search.text compnentsSeparatedBy:@" "];
Currently, I have this predicate which kinda works:
[NSPredicate predicateWithFormat@"word contains[cd]%@ AND word contains [cd]%@",words[0],words[1],words[2]..]
But, the problem is that I don’t know how many words the user will type in, so, Is there a way to search the column ‘word’ using NSArray of tokens?
Check out:
[NSCompoundPredicate andPredicateWithSubpredicates:/*Your Array Of Contains Predicates Here*/]Although I’m unclear from your question if you want to be using the
INcommand to search an array/set of objects.[NSPredicate predicateWithFormat:@"word IN %@", setOfWords]