Created
April 30, 2015 02:30
-
-
Save superarts/a8234c51ec1665dc6fdb to your computer and use it in GitHub Desktop.
LFTableController+SearchDisplayController
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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