M
M
MagoVinch2014-02-04 15:24:27
Objective-C
MagoVinch, 2014-02-04 15:24:27

How to do dynamic string search in IOS?

There is an array with strings, you need to do a dynamic search for strings. How to implement?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
R
Roman, 2014-02-04
@MagoVinch

For example like this:

+ (NSArray *)findText:(NSString *)searchText inArrayOfStrings:(NSArray *)arrayOfStrings
{
  NSPredicate *searchPredicate = [NSPredicate predicateWithFormat: @ "(SELF contains[cd] %@)", searchText];

  return [arrayOfStrings filteredArrayUsingPredicate:searchPredicate];
}

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question