https://github.com/rushisangani/rswebsearchtableview
https://github.com/rushisangani/rswebsearchtableview
Last synced: 7 months ago
JSON representation
- Host: GitHub
- URL: https://github.com/rushisangani/rswebsearchtableview
- Owner: rushisangani
- Created: 2016-06-12T11:48:19.000Z (over 9 years ago)
- Default Branch: master
- Last Pushed: 2016-06-13T09:47:08.000Z (over 9 years ago)
- Last Synced: 2025-01-20T09:26:09.680Z (9 months ago)
- Language: Objective-C
- Size: 56.6 KB
- Stars: 2
- Watchers: 3
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# RSWebSearchTableView
A **TableView** with search functionality using API.
**RSWebSearchTableView** with searchBar as a headerView manages all the stuff related to search using API with minimum effort required. No need to write code for creating UITableView and UISearchBar.

## Features
- Enable search in UITableView itself, no need to write code in ViewController.
- Get searched results using delegate method.
- Customizable searchBar.
- Customizable Label when "No Result found".## How To Use
### RSWebSearchTableView
```objective-c
#pragma mark- TableView Setup-(void)configureTableView {
__weak typeof(self) weakSelf = self;
/* setup tableView */
[self.tableView setupTableViewCellConfiguration:^(id cell, id object, NSIndexPath *indexPath) {
// set data for TableViewCell} forCellIdentifier:@"cell"];
/* enable web search and specify placeHolder */
[self.tableView enableWebSearchWithPlaceHolder:@"Search by Name" andActionHandler:^(NSString *searchString) {
/* API call for search string */
[weakSelf getResultsForSearchString:searchString];
}];
}-(void)getResultsForSearchString:(NSString *)string {
/* send request here */
id response = nil; /* get response here */
[self didGetResponseFromServer:response];
}#pragma mark- Success
-(void)didGetResponseFromServer:(id)response {
NSMutableArray *array = response; /* get search results into array */
/* inform tableview about search results and pass dataArray */
[self.tableView didCompleteSearchWithCompletion:array];
}#pragma mark- Failure
-(void)didFailToGetResults {
/* inform tableview in failure */
[self.tableView didFailToSearch];
}#pragma mark- UITableViewDelegate methods
- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath {
/* get selected object here */
id selectedObject = [self.tableView.dataSourceArray objectAtIndex:indexPath.row];
}```
## License
RSWebSearchTableView is released under the MIT license. See LICENSE for details.