ios - TableView Inside a UITableViewCell - must register a nib or class -


i'm putting uitableview inside uitableviewcell.

i've extended class of uitableviewcell ,uitableviewdatasource, uitableviewdelegate.

made @iboutlet var tableview: uitableview!

added following:

override init(style: uitableviewcellstyle, reuseidentifier: string?) {         super.init(style: style , reuseidentifier: reuseidentifier)         setuptable()     }      required init(coder adecoder: nscoder) {         super.init(coder: adecoder)!         setuptable()     }      override func awakefromnib() {         super.awakefromnib()         setuptable()     } 

where setuptable() implemented as:

func setuptable(){         tableview?.delegate = self         tableview?.datasource = self         //tableview.register(uinib(nibname: "availabletimingstableviewcell", bundle: nil), forcellreuseidentifier: "timingcell")     } 

if keep commented line in setuptable() get:

'unable dequeue cell identifier timingcell - must register nib or class identifier or connect prototype cell in storyboard'

if uncomment comment get:

fatal error: unexpectedly found nil while unwrapping optional value

on same line.

after setuptable() i've implemented them as:

func tableview(_ tableview: uitableview, numberofrowsinsection section: int) -> int {         return 3     }      func numberofsectionsintableview(tableview: uitableview) -> int {         return 1     }      func tableview(_ tableview: uitableview, cellforrowat indexpath: indexpath) -> uitableviewcell {          let cell = tableview.dequeuereusablecell(withidentifier: "timingcell", for: indexpath) as?availabletimingstableviewcell          cell?.daynamelabel.text = "wednesday"         cell?.timelabel.text = "01:00 pm - 03:00 pm"          return (cell)!     } 

edit here screenshots of class names. i've double checked okay per comments , answer.
enter image description here enter image description here

i think setuptable() in init() called soon. @ point view not loaded. setup in viewdidload(), don't comment out registering cell. other code looks good.


Comments

Popular posts from this blog

angular - Ionic slides - dynamically add slides before and after -

minify - Minimizing css files -

Add a dynamic header in angular 2 http provider -