Identify cell in static tableview by name and not indexPath.row



I am wondering if there is a way to address a cell or row in a static tableview by a name or identifier instead of indexPath.row

For example in this case:

override func tableView(_ tableView: UITableView, didSelectRowAt indexPath: IndexPath) {
  if indexPath.section == 0 && indexPath.row == 2 {
  print("selecte startDate")
  toggleDatepicker(pickerType: "startDate")
  } else if indexPath.section == 0 && indexPath.row == 4 {
  print("selecte endDate")
  toggleDatepicker(pickerType: "endDate")


If I now add or remove a row in the tableview, I have to adjust the whole code to account for the new row numbers. If I could instead say something like


indexPath.row.Cellname == ‘startDateCell’


that would be great.

Any ideas if that is possible? I have already googled and checked stackoverflow but either I am searching for the wrong key words or it is simply not possible …




Powered by WPeMatico


You may also like...

Comments are closed.