i'm trying present array of names cells of tableview controller.
here's code:
import uikit class tableviewcontroller: uitableviewcontroller { var names = ["aa", "ab", "cc"] override func numberofsectionsintableview(tableview: uitableview) -> int { return 0 } override func tableview(tableview: uitableview, numberofrowsinsection section: int) -> int { return names.count } override func tableview(tableview: uitableview, cellforrowatindexpath indexpath: nsindexpath) -> uitableviewcell { let cell = tableview.dequeuereusablecellwithidentifier("mycell", forindexpath: indexpath) cell.detailtextlabel!.text = names[indexpath.row] return cell } }
when simulate it, nothing has appeared cells!
what's wrong code! compiler did not give me errors.
update number of sections. problem solved.
override func numberofsectionsintableview(tableview: uitableview) -> int { return 1 }
Comments
Post a Comment