[filteredArray filterUsingPredicate: [NSPredicate predicateWithFormat:@"self BEGINSWITH[cd] %@", searchText]];
filteredArray contains simple NSStrings. [hello, my, get, up, seven, etc ...];
It will give all lines starting with searchText .
But if the string is a combination of words like "my name" and searchText = name . How would NSPredicate look to achieve this?
UPDATE: And how should it be if I want to get the 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 first, it should display lines starting with searchText , and only after those that contain searchText .
source share