https://github.com/hitendradeveloper/hssearchable
The easiest way to search from UITableView using UISearchBar or UISearchBarController in the minimum line of code.
https://github.com/hitendradeveloper/hssearchable
cocoapods datamodel hitendra hitendra-solanki hitendra-solanki-ios hssearchable modal pods protocol serchable solanki swift swift-protocol swift5 uisearchbar uitableview uiviewcontroller
Last synced: 28 days ago
JSON representation
The easiest way to search from UITableView using UISearchBar or UISearchBarController in the minimum line of code.
- Host: GitHub
- URL: https://github.com/hitendradeveloper/hssearchable
- Owner: hitendradeveloper
- License: mit
- Created: 2017-08-28T05:33:04.000Z (over 7 years ago)
- Default Branch: master
- Last Pushed: 2019-02-15T11:43:48.000Z (over 6 years ago)
- Last Synced: 2025-04-24T02:53:33.050Z (28 days ago)
- Topics: cocoapods, datamodel, hitendra, hitendra-solanki, hitendra-solanki-ios, hssearchable, modal, pods, protocol, serchable, solanki, swift, swift-protocol, swift5, uisearchbar, uitableview, uiviewcontroller
- Language: Swift
- Homepage: https://medium.com/@hitendrahckr
- Size: 534 KB
- Stars: 10
- Watchers: 2
- Forks: 1
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# HSSearchable
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](https://guides.cocoapods.org/using/getting-started.html "more info"))
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 self.name + " " + self.city //this will search from the name and city both//return self.name //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() {
super.viewDidLoad()
self.searchbar.delegate = self.usersData
self.usersData.searchingCallBack = { isSearching, searchText in
print("searching Text:= \(searchText)")
self.tableView.reloadData()
}
self.loadDummyData()
}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