2

I keep getting

unable to dequeue a cell with identifier TransactionCell - must register a nib or a class for the identifier or connect a prototype cell in a storyboard

But I don't understand why. I set up an identifier in storyboard (can't upload screenshot - not enough reputation).

Here is my actual code

  override func tableView(tableView: UITableView, cellForRowAtIndexPath indexPath: NSIndexPath) -> UITableViewCell {

    let cell = self.tableView.dequeueReusableCellWithIdentifier("TransactionCell", forIndexPath: indexPath) as TransactionCell


    var transaction: Transaction

    transaction = Manager.sharedManager.transactions[indexPath.row]

    var dateFormatter = NSDateFormatter()
    dateFormatter.dateFormat = "yyyy-MM-dd"

    var myAmount = String(transaction.amount)
    cell.amountLabel?.text = myAmount
    cell.dateLabel?.text = dateFormatter.stringFromDate(transaction.date)
    cell.descriptionLabel?.text = transaction.description

    return cell
}
Eric Aya
  • 69,473
  • 35
  • 181
  • 253
Romaldowoho
  • 405
  • 1
  • 7
  • 20
  • There is definitely something set up incorrectly in Interface Builder. Make sure your Table View Content is set to "Dynamic Prototypes". Check some of the solutions here: http://stackoverflow.com/questions/19084274/xcode-unable-to-dequeue-a-cell-with-identifier?rq=1 – bjtitus Dec 10 '14 at 20:39

2 Answers2

4

I set up an identifier in storyboard

Maybe. But:

  • That identifier is not TransactionCell. Or:

  • You put it in the wrong place - it isn't a cell identifier. Or:

  • You forgot to set the class of the table view controller in that scene in the storyboard to the class of the table view controller that your code is in.

matt
  • 515,959
  • 87
  • 875
  • 1,141
2

My problem was that I'd set the Accessibility Identifier in the Identity Inspector and NOT in the Attributes Inspector... :doh:

gsaslis
  • 3,066
  • 2
  • 26
  • 32