ios - Swift, Xib variables pass data to variable -
i cant seem make work way want.
i have created xib file pick table cell. want add variables modify before returning cell tableview.
func tableview(tableview: uitableview, cellforrowatindexpath indexpath: nsindexpath) -> uitableviewcell { let cell:makemetableviewcell = self.tableview.dequeuereusablecellwithidentifier("t5cell") as! makemetableviewcell cell.questionnumberlabel.text = "\(indexpath.row + 1)." cell.customvariable = "\(indexpath.row + 1)." return cell } swift xib
import uikit class take5tableviewcell: uitableviewcell { @iboutlet weak var questionnumberlabel: uilabel! var customvariable = "" override func awakefromnib() { super.awakefromnib() println("label: \(questionnumberlabel.text)") println("variable: \(customvariable)") } override func setselected(selected: bool, animated: bool) { super.setselected(selected, animated: animated) // configure view selected state } } the output i'm getting is:
label: optional("1.") variable: label: optional("1.") variable: label: optional("1.") variable: label: optional("1.") variable: label: optional("1.") variable: the output hoping label: 1..2..3, variable: 1..2..3
Comments
Post a Comment