Q:

Multiple Tableviews inside Collection-view

I am working on Multiple Tableviews inside Collection-view. And I followed this article. But inside the cellForRowAt indexPath method I am getting following error.

Value of type 'UITableViewCell' has no member 'lblLab'
  Value of type 'UITableViewCell' has no member 'lblLab'
  Value of type 'UITableViewCell' has no member 'lblMedicine'

I have already created the separate classes for all the three tableview cells in which all the three labels are already mentioned.
Below is my code for the same which is written inside collection-view cell class.
 func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell {
    var cell : UITableViewCell;
    if tableView == tableLAB {
        cell = tableView.dequeueReusableCell(withIdentifier: "labCell", for: indexPath) as! LabTableCell;
        cell.lblLab!.text = arr1[indexPath.row];
    } else if tableView == tableDIAGNOSIS {
        cell = tableView.dequeueReusableCell(withIdentifier: "diagnosisCell", for: indexPath) as! DiagnosisTableCell;
        cell.lblDiagnosis!.text = arr1[indexPath.row];
    } else if tableView == tableMEDICINE {
        cell = tableView.dequeueReusableCell(withIdentifier: "medicineCell", for: indexPath) as! MedicineTableCell;
        cell.lblMedicine!.text = arr1[indexPath.row];
    }

    return cell;
}

can you tell me what I am doing wrong? Thanks in advance.

A:

You can try
  func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell {

    if tableView == tableLAB {
        let cell = tableView.dequeueReusableCell(withIdentifier: "labCell", for: indexPath) as! LabTableCell;
        cell.lblLab!.text = arr1[indexPath.row];
         return cell;
    } else if tableView == tableDIAGNOSIS {
       let cell = tableView.dequeueReusableCell(withIdentifier: "diagnosisCell", for: indexPath) as! DiagnosisTableCell;
        cell.lblDiagnosis!.text = arr1[indexPath.row];
         return cell;
    } else {
        let cell = tableView.dequeueReusableCell(withIdentifier: "medicineCell", for: indexPath) as! MedicineTableCell;
        cell.lblMedicine!.text = arr1[indexPath.row];
         return cell;
    }

}

