I would like to figure out the NSPredicate that will search my Core data for words that begins with:
For example:
description field in the core data has text like this:
My name is Mike
My name is Moe
My name is Peter
My name is George
If I search ‘My name is’ I need to get the 3 lines
If I search ‘My name is M’ I need to get the first 2 lines
I tried the code below, but can’t get what I need. My guess I need a regular expression, but not sure how to do it.
[NSPredicate predicateWithFormat:@"desc beginswith [cd] %@",word];
I did it this way recently and worked fine. Try it out. I see I don’t have
[cd]andbeginswithbutcontains. You could give it a try.After reading the comments on the starting post:
First of all, you should split up the words in the string from the textfield:
Then doing the same like you first would:
Instead of NSLogging the words you could add them to an array of course.