I am having array contains model, in that model i am haveing 3 objects as String say, firstName
, lastName
and action
,
i am using the following predicate
let resultPredicate = NSPredicate(format: "lastName CONTAINS [c] %@ OR firstName CONTAINS [c] %@ OR action CONTAINS [c] %@", searchText, searchText, searchText)
tableDataArray = dataSourceArray.filter { resultPredicate.evaluateWithObject($0) }
if i search the string based on firstName
or lastName
its working fine. But if i search the string which is present in the action
its not filtering.
Any help regarding this will be appreciated.
Really its strange... i unable to find the solution for this. But i found the alternate way to filter the array without using predicate.
tableDataArray = dataSourceArray.filter {$0.firstName.containsString(searchText) || $0.lastName.containsString(searchText) || $0.action.containsString(searchText) }