Im new to the swift, I am trying to filter name from an array using the search bar in console am getting what I entered in the search bar but filtering with predicate im not
let array = self.caseListOfBooker.filter{$0.person_of_interest.contains(searchString)}
You are getting array of CaseDetails
objects and trying to cast to array of String
It fails. You need to get string values from the CaseDetails
object and join them
Use
filteredString = array.map { $0.person_of_interest }
Or
for caseDetail in array {
filteredString.append(caseDetail.person_of_interest)
}
Instead of
if let list = array as? [String]{
filteredString=list
}