ios - Access variable from UITableViewCell in the TableViewController for specific cells? -
i new coding ios. have tableviewcell has boolean in (to check if button has been pressed).
class chintwotableviewcell: uitableviewcell { @iboutlet var countlabel: uilabel! @iboutlet var namelabel: uilabel! @iboutlet var bodytext: uitextview! var likecheck:bool = false // other code @ibaction func liketapped(sender: anyobject) { if((likecheck) == false) { sender.settitlecolor(uicolor.redcolor(), forstate: uicontrolstate.normal) likecheck = true } else { sender.settitlecolor(uicolor.whitecolor(), forstate: uicontrolstate.normal) likecheck = false } } }
i access boolean in tableviewcontroller, , check if true, stuff, if false, stuff.
how can check pertains correct row in other class?
rather creating bool directly in uitableviewcell suggest create model class.
the view controller keep array of model classes it. in cellforrow callback controller can pass model class cell , cell can modify if required.
Comments
Post a Comment