-1

I have two custom table views with two custom cells.

self.detourTblView.delegate = self
self.detourTblView.dataSource = self
self.dropDownLuggageTblView.delegate = self
self.dropDownLuggageTblView.dataSource = self

And this is how I fill data.

func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell {
    if tableView == self.dropDownLuggageTblView {
        let luggage_cell = tableView.dequeueReusableCell(withIdentifier: "luggage_cell", for: indexPath) as! LuggageCell

        luggage_cell.luggageTypeTxt.text = luggageTypeList[indexPath.row]
        return luggage_cell

    }

    if tableView == self.detourTblView {
        let detour_cell = tableView.dequeueReusableCell(withIdentifier: "detour_cell", for: indexPath) as! DetourCell
        detour_cell.selectionTime.text = detourSelectionList[indexPath.row]
        return detour_cell        
    }
    return cell    
}

This gives me following error, Terminating app due to uncaught exception

'NSInternalInconsistencyException', reason: 'unable to dequeue a cell with identifier luggage_cell - must register a nib or a class for the identifier or connect a prototype cell in a storyboard' *** First throw call stack:

But I have given both identifiers in the storyboard. Why is this occur?

Dávid Pásztor
  • 51,403
  • 9
  • 85
  • 116
Aneef
  • 3,641
  • 10
  • 43
  • 67
  • Are you sure you gave the exact identifier `luggage_cell` to your prototype cell in `dropDownLuggageTblView` in `Storyboard`? It looks like a typo problem to me. – Dávid Pásztor Jul 31 '17 at 10:45
  • `I have given both identifiers in the storyboard` - Obviously not if you chose that answer. To make this question more valuable to others, you should explain why you thought you had put the identifiers in the storyboard. – AgRizzo Jul 31 '17 at 10:59

1 Answers1

1

The reason of the error is that no cell in your storyboard or in xib file have the identifier : "luggage_cell"
This is an example on how to add an identifier with UICollectionView and a Prototype Cell enter image description here

Alain Berrier
  • 621
  • 6
  • 23