Search code examples
iosswiftwatchkitsectionswkinterfacetable

Sections in WKInterfaceTable


I am trying to create a table with sections having varying number of rows. I saw the solution given here How to create sections in WKInterfaceTable and tried it as follows:

tableView.setRowTypes(rowTypes);
for q in 0...rowTypes.count-1 {
    if (rowTypes[q] == "teamSection") {
        let row = tableView.rowControllerAtIndex(q) as? teamSection;
    }
    else {
        let row = tableView.rowControllerAtIndex(q) as? teamRow;
    }
}

I have my rowTypes as follows:

let rowTypes = ["teamSection", "teamRow", "teamSection", "teamRow", "teamRow", "teamRow", "teamRow", "teamRow", "teamRow", "teamRow", "teamRow"];

I was expecting 11 rows but am only getting 9 which are all of the teamRow type and none of the teamSection. Can anyone spot what am doing wrong?


Solution

  • It looks like teamSection isn't a valid row type. Are you sure you've set up the table in the storyboard with two rows and set the identifier correctly for one of them as "teamSection"?