0

I'm creating the TableViewController programmatically (not using a xib or storyboard) in a ViewController (handling several view and view controllers), like this:

- (void)viewDidLoad
{
    [super viewDidLoad];

    tableViewController = [[UITableViewController alloc]initWithStyle:UITableViewStylePlain];
    [self.view addSubview:tableViewController.tableView];
}

When running, the program halts with the error:

Assertion failure in -[UITableView dequeueReusableCellWithIdentifier:forIndexPath:], /SourceCache/UIKit_Sim/UIKit-2372/UITableView.m:4460 Terminating app due to uncaught exception 'NSInternalInconsistencyException', reason: 'unable to dequeue a cell with identifier Cell - must register a nib or a class for the identifier or connect a prototype cell in a storyboard'

Debugging reveals that the tableView is blank when added to self.view.

Do I need to do some extra, manual initialization for the tableView, normally being found in a nib file?

voromax
  • 3,369
  • 2
  • 30
  • 53
  • looks like this might be a duplicate of: http://stackoverflow.com/questions/12737860/assertion-failure-in-dequeuereusablecellwithidentifierforindexpath – Joe Nov 05 '12 at 16:54

1 Answers1

0

Thank you all for editing and answering my question. On more careful reading, the error message spell it out: "must register a nib or a class for the identifier or connect a prototype cell in a storyboard". This detail is rarely mentioned in guides, samples and tutorials.

Stackoverflow! If it ain't there, it ain't anywhere!