ios - Customer Cell returns nil when unwrapping an Optional Value -



ios - Customer Cell returns nil when unwrapping an Optional Value -

i have custom table view cell. in story board, have implemented uilabel , uibutton. want give label different value everytime reused. storyboard connections good. if utilize cell.textlabel.text = episodetitle works, if set text property of uilabel error

fatal error: unexpectedly found nil while unwrapping optional value

i have tried registering class doesn't work. not sure anymore. there tons of similar posts on none helped.

this cellforrowatindexpath:

override func tableview(tableview: uitableview, cellforrowatindexpath indexpath: nsindexpath) -> uitableviewcell { //tableview.registerclass(episodecell.self, forcellreuseidentifier: "episode") var cell = tableview.dequeuereusablecellwithidentifier("episode", forindexpath: indexpath) episodecell cell = episodecell(style: uitableviewcellstyle.subtitle, reuseidentifier: "episode") allow episode: mwfeeditem? = episodestodisplay.objectatindex(indexpath.row) as? mwfeeditem if episode != nil { //process episode var episodetitle: nsstring = episode?.title string! //cell.textlabel.text = episodetitle cell.episodetitle.text = episodetitle } homecoming cell }

and custom cell:

class episodecell: uitableviewcell { var progress: float? @iboutlet weak var episodetitle: uilabel! }

the error here:

var cell = tableview.dequeuereusablecellwithidentifier("episode", forindexpath: indexpath) episodecell cell = episodecell(style: uitableviewcellstyle.subtitle, reuseidentifier: "episode")

you dequeue cell , assign cell variable, , next replace instance brand new one. remove line:

cell = episodecell(style: uitableviewcellstyle.subtitle, reuseidentifier: "episode")

ios uitableview swift

Comments

Popular posts from this blog

maven fortify plugin : Unable to load build session with ID XXXXX .. See log file for more details -

c# - Primavera WebServices does not return any data -

android - Display emoji panel with genymotion - keyboard/touch input? -