ios - Two table views in view controller: Swift -
i have uitableview prototype cells takes whole page. have uibutton on bottom should display pop-up static uitableview when tapped. i'm struggling account pop-up table view in cellforrowatindexpath.
func tableview(tableview: uitableview, cellforrowatindexpath indexpath: nsindexpath) -> uitableviewcell { let result: uitableviewcell if tableview == self.tableview { var cell = self.tableview.dequeuereusablecellwithidentifier("cell", forindexpath: indexpath) as! uitableviewcell cell.textlabel!.text = array[indexpath.row] result = cell } else if tableview == self.popuptableview { var popupcell = self.popuptableview.dequeuereusablecellwithidentifier("popupcell", forindexpath: indexpath) as! uitableviewcell popupcell.textlabel!.text = popuparray[indexpath.row] result = popupcell } return result } i'm getting error @ return result, variable 'result' used before being initialized, i'm declaring @ top. going wrong this?
you need have exhaustive choices. it's possible result never gets initialized because checks "if" , "else if". happens if tableview not either "self.tableview" or "self.popuptableview"?
the simple fix (if plan on having these two) change "else if" simple "else". way result initialized.
Comments
Post a Comment