Latest 4.2
License MIT
Platforms ios 8.0, requires ARC
Frameworks UIKit

Easiest way to search from UITableView using UISearchBar in minimum line of code in UIViewController


How to integreat source?

  1. Directly drag and drop the HSSearchable.swift into your xcode project.

  2. Most recommanded: install via cocoapods (How to use cocoapods)

    pod ‘HSSearchable’

How to use in code ? Just follow the simple steps :)

import HSSearchable

//Suppose this is your datamodel
struct UserDM {
  var name: String
  var city: String
  1. extend your class or Structure using the SearchableData delegate

    extension UserDM: SearchableData {
    var searchValue: String{
    return + " " + //this will search from the name and city both

      //return //this will search from the name only


  2. Create a variable of ‘SearchableWrapper’ in the viewController as property

    var usersData = SearchableWrapper()
    var users: [UserDM] { //use this array as you are using array for your tableview controller
    return self.usersData.dataArray as! [UserDM]

  3. Set the searchbar delegate and Searching callback

    override func viewDidLoad() {
    self.searchbar.delegate = self.usersData
    self.usersData.searchingCallBack = { isSearching, searchText in
    print("searching Text:= (searchText)")

  4. Set the local array or load data from the server usign API|Webservice call

    func loadDummyData(){
          //This is just an example data
          let user1 = UserDM(name: "Hitendra Solanki", city: "Ahmedabad")
          let user2 = UserDM(name: "Justina Flores", city: "Arizona")
          let user3 = UserDM(name: "Lisa Minick", city: "Casper")
          let user4 = UserDM(name: "Moises Patrick", city: "Reno")
          let user5 = UserDM(name: "Martha Fisher", city: "Tacoma")
          let user6 = UserDM(name: "Martha McDaniel", city: "Irvine")
          let array : Array<UserDM = [
          //In most of the cases, this data will come from the server side
          self.usersData.serverArray = array;
  5. Optional Setps:
    HSSearchable also supports the optional customDelegate, using this you can handle default UISearchabarDelegate methods in your own viewControllers.

      self.usersData.customDelegate = self //implement UISearchbarDelegate in your class       

It’s Done

It's Done


twitter: @hitendrahckr

Latest podspec

    "name": "HSSearchable",
    "platforms": {
        "ios": "8.0"
    "summary": "The easiest way to search from UITableView using UISearchBar or UISearchBarController in the minimum line of code.",
    "requires_arc": true,
    "version": "4.2",
    "license": {
        "type": "MIT",
        "file": "LICENSE"
    "authors": {
        "Hitendra Solanki": "[email protected]"
    "homepage": "",
    "source": {
        "git": "",
        "tag": "4.2"
    "frameworks": "UIKit",
    "source_files": "HSSearchable/**/HSSearchable.swift",
    "swift_version": "4.2"

Pin It on Pinterest

Share This