In iOS we can use Predicates in order to get fast response. Mostly iOS developers use Predicates in search functionality to filter it as user types in search bar textfield.
Let suppose you have an array named as youDataArray which contains string data and you want to apply filter using Predicate then take another array named as filteredArray
I'm taking searchText as a search bar textfield here.
NSPredicate *predicate = [NSPredicate predicateWithFormat:@"self CONTAINS[cd] %@",searchText];
filteredArray = [youDataArray filteredArrayUsingPredicate:predicate] ;
There are several predicate formats. Hope this will help.
Happy Coding!!!
0 Comment(s)