0

I'm loading interfacetable values from context send from iOS application. The data passing was successful but the tableview method

rowController(at: index)

Is returning nil Value and numberOfRows variable was still 0 after line of code

tableView.setNumberOfRows(3, withRowType: "deviceRow")

My overall code is

func setupTable() {
    tableView.setNumberOfRows(devicesArray.count, withRowType: "deviceRow2")

    for (index, device) in self.devicesArray.enumerated() {
        if let row = tableView.rowController(at: index) as? MeasurementCell {

            row.deviceNameLabel.setText(device)
            row.readingLabel.setText(self.readingsArray[index])
            let statusColor = colorWithHexString(hex: self.colorsArray[index])
            // row.backgroundGroupView.setBackgroundColor(statusColor.withAlphaComponent(0.2))
            row.readingLabel.setTextColor(statusColor)
            row.dateLabel.setText(self.datesArray[index])
            row.readingLabel.setTextColor(self.getColor(fromString: self.colorsArray[index]))
            row.readingLabel.sizeToFitWidth()
        }
    }

Is there any workaround for the issue? Suggestions are highly appriciated.

Ashley Mills
  • 50,474
  • 16
  • 129
  • 160
Saranjith
  • 11,242
  • 5
  • 69
  • 122
  • Only logical way where numberOfRows is 0, even if you explicitly set it to 3 is that tableView is nil – Adam Sep 11 '18 at 09:36

1 Answers1

1

In Identity inspector of interfaceController

It was

enter image description here

When I changed the same as shown below, it worked by apple magic. enter image description here

Don't know reason behind how does this fix worked. Hope anyone in future may help this answer.

Saranjith
  • 11,242
  • 5
  • 69
  • 122