I am using tableview with custom cell in swift 3.0. I take a textview and give outlet of class of tabelview cell and accessing in tableview delegate method but its showing me error like unexpectedly found nil while unwrapping an Optional value
here is my code. Record is array
Chek this Screenshot. FYI I have taken A new custom class and Give Outlet to it but same problem ocuured
func tableView(_ tableView: UITableView, numberOfRowsInSection section: Int) -> Int {
return record.count
}
func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell {
tableView.register(TableViewCell.self, forCellReuseIdentifier: "TableViewCell")
let cell = tableView.dequeueReusableCell(withIdentifier: "TableViewCell", for: indexPath) as! TableViewCell
if let str = record.object(at: indexPath.row) as? String {
print(cell.txtview)
cell.txtview.text = str
}
return cell
}
Its perfectly working in Static cell but in custom cell it showing me error.
cell.textview
is not taken from custom cell
Please help me with it