Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save superarts/a8234c51ec1665dc6fdb to your computer and use it in GitHub Desktop.
Save superarts/a8234c51ec1665dc6fdb to your computer and use it in GitHub Desktop.
LFTableController+SearchDisplayController
class ICSearchController: LFTableController {
var source_search: LFTableDataSource!
//@IBOutlet var search_controller: UISearchDisplayController!
//@IBOutlet var search_bar: UISearchBar!
override func viewDidLoad() {
super.viewDidLoad()
reload_featured()
reload_search()
}
func reload_search() {
source_search = LFTableDataSource(table: searchDisplayController!.searchResultsTableView)
//searchDisplayController!.searchResultsDelegate = source_search
//searchDisplayController!.searchResultsDataSource = source_search
}
func reload_featured() {
source.counts = [5]
source.func_cell = {
(path: NSIndexPath) -> UITableViewCell in
let cell = self.table.dequeueReusableCellWithIdentifier("ICFeaturedCell") as UITableViewCell
cell.textLabel!.text = "Featured"
cell.detailTextLabel!.text = String(path.row)
return cell
}
table.reloadData()
}
func searchDisplayController(controller: UISearchDisplayController, shouldReloadTableForSearchString s: String!) -> Bool {
//LF.log("should search", s)
if let i = s.toInt() {
source_search.counts = [i]
}
source_search.func_cell = {
(path: NSIndexPath) -> UITableViewCell in
let cell = self.table.dequeueReusableCellWithIdentifier("ICFeaturedCell") as UITableViewCell
cell.textLabel!.text = "Search"
cell.detailTextLabel!.text = String(path.row)
return cell
}
return true
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment