[filteredArray filterUsingPredicate:
[NSPredicate predicateWithFormat:@"self BEGINSWITH[cd] %@", searchText]];
filteredArray contains simple NSStrings. [hello, my, get, up, seven, etc…];
It will give all strings that begin with searchText.
But if string will be a combination of words like “my name is”, and searchText = name. What would a NSPredicate look like to achieve this?
UPDATE:
And how would it have to be if i want to a result with searchText = name, but not with searchText = ame? Maybe like this:
[filteredArray filterUsingPredicate:
[NSPredicate predicateWithFormat:
@"self BEGINSWITH[cd] %@ or self CONTENTS[cd] %@",
searchText, searchText]];
But it should first display the strings that begin with searchText and only after those which contain searchText.
EDIT after expansion of question
This will have the results in the desired order without duplicate entries.