Building Searchable Data Source Methods
The number of items displayed in a table changes as users search. A shorter search string generally matches more items than a longer one. You report the current number of rows for each table. The number of rows changes as the user updates text in the search field. To detect whether the table view controller or the search display controller is currently in charge, check the passed table view parameter. Adjust the row count accordingly:
- (NSInteger)tableView:(UITableView *)aTableView numberOfRowsInSection:(NSInteger)section { if (aTableView == searchController.searchResultsTableView) return [crayons filterWithString:searchBar.text]; return [crayons countInSection:section]; ...
Get The Core iOS Developer’s Cookbook, Fifth Edition now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.