Tuesday, 15 June 2010

swift - Why am I getting a nil for a UITableViewCell's UILabel? -



swift - Why am I getting a nil for a UITableViewCell's UILabel? -

why getting 'nil' error/uilabel during sec pass thru table cell listing iteration?

1) within cell 2) within cell fatal error: unexpectedly found nil while unwrapping optional value (lldb) po cell?.contentview.viewwithtag(titlelabeltag) nil

here link elements in code; , register cell:

class diarytableviewcell: uitableviewcell { @iboutlet weak var titlelabel: uilabel! @iboutlet weak var subtitlelabel: uilabel! @iboutlet weak var leftimageview: uiimageview! @iboutlet weak var rightimageview: uiimageview! } class diarytableviewcontroller: uitableviewcontroller { allow kcellidentifier = "diarycell" var cellnib:uinib? var diarycell:diarytableviewcell? var objects = nsmutablearray() //...global var. override func viewdidload() { self.title = "my diary" cellnib = uinib(nibname: "tableviewcells", bundle: nil) tableview.registerclass(diarytableviewcell.self, forcellreuseidentifier: kcellidentifier) } ...

yet i'm getting runtime error here:

here's in console:

1) within cell fatal error: unexpectedly found nil while unwrapping optional value (lldb) po cell!.titlelabel nil

what's missing here?

it's pretty bad thought select view tag. it's much improve thought subclass uitableviewcell , give property access elements.

swift uilabel null tableviewcell

No comments:

Post a Comment