ios - How can i call search tableview delegate with SQLLite -
i prepared tableview. in screen below, there sqllite db. . search delegate function did not work.
var dictionaries = [[string:anyobject]]() // var filtereddogs = [[string:anyobject]]() var searchcontroller: uisearchcontroller! var resultscontroller = uitableviewcontroller()
func updatesearchresultsforsearchcontroller(searchcontroller: uisearchcontroller) { self.filtereddogs = self.dictionaries.filter{(dict:[string:anyobject]) -> bool in if dict.lowercasestring.containsstring(self.searchcontroller.searchbar.text!.lowercasestring) { return true } else { return false } } //update results table self.resultscontroller.tableview.reloaddata() } func tableview(tableview: uitableview, cellforrowatindexpath indexpath: nsindexpath) -> uitableviewcell { let cell = tableview.dequeuereusablecellwithidentifier("cell", forindexpath: indexpath) as! rowtableviewcell if tableview == self.tableview { let row = self.dictionaries[indexpath.row] cell.language1.text = row["foreign_language"] as? string cell.language2.text = row["native_language"] as? string } else { let row = self.filtereddogs[indexpath.row] cell.language1.text = row["foreign_language"] as? string cell.language2.text = row["native_language"] as? string } return cell } func tableview(tableview: uitableview, didselectrowatindexpath indexpath: nsindexpath) { let row = self.dictionaries[indexpath.row] self.speechtext((row["foreign_language"] as? string)!, language: (row["language"] as? string)!) let indexpath = self.tableview.indexpathforselectedrow if((indexpath) != nil){ self.tableview.deselectrowatindexpath(indexpath!, animated: true) } }
func tableview(tableview: uitableview, cellforrowatindexpath indexpath: nsindexpath) -> uitableviewcell { let cell = tableview.dequeuereusablecellwithidentifier("cell", forindexpath: indexpath) as! rowtableviewcell if tableview == self.tableview { let row = self.dictionaries[indexpath.row] cell.language1.text = row["foreign_language"] as? string cell.language2.text = row["native_language"] as? string } else { let row = self.filtereddogs[indexpath.row] cell.language1.text = row["foreign_language"] as? string cell.language2.text = row["native_language"] as? string } return cell }
func tableview(tableview: uitableview, didselectrowatindexpath indexpath: nsindexpath) { let row = self.dictionaries[indexpath.row] self.speechtext((row["foreign_language"] as? string)!, language: (row["language"] as? string)!) let indexpath = self.tableview.indexpathforselectedrow if((indexpath) != nil){ self.tableview.deselectrowatindexpath(indexpath!, animated: true) } }
Comments
Post a Comment