ios - Swift Thread 1: EXC_BAD_INSTRUCTION when I try to change a uilabel.text -
i know there lot of stack overflow questions out there, none of answers can find work me. using custom uitableviewcell
class called chillercell
. here code:
import uikit class chillercell: uitableviewcell { @iboutlet weak var iconlabel: uilabel! @iboutlet weak var boldlabel: uilabel! @iboutlet weak var italiclabel: uilabel! func configurecellwithevent(event: event){ boldlabel.text = "\(event.eventname)" italiclabel.text = "\(event.eventdescription)" } }
i thread 1 runtime error on line boldlabel.text = "\(event.eventname)"
i made own event
class, , yes, event.eventname
, event.eventdescription
of type string
, not nil
.
edit: forgot mention, boldlabel , italiclabel not plain text, attributed text.
try this, work if event object having eventname & eventdescription string:
func configurecellwithevent(event: event){ var attributedstring = nsmutableattributedstring(string:"(event.eventname)") , boldlabel.text = attributedstring boldlabel.text = attributedstring italiclabel.text = attributedstring }
Comments
Post a Comment