JetSky JetSky - 1 month ago 4
Swift Question

Can I search subtitle in tableview?

I have 2 labels: Title and Subtitle on each tableview cell. Now I can search for the title. And I want to search subtitle with search bar,

How can I do it?

Here is how my app looks like:

enter image description here

func filterContentForSearchText(searchText: String, scope: String = "All") {
    filteredObjects = objects.filter { object in

  return object.title.lowercaseString.containsString(searchText.lowercaseString) || object.subtitle.lowercaseString.containsString(searchText.lowercaseString)



This function searches through the subtitles!

Happy coding!