0
votes

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?

1
looks like this might be a duplicate of: stackoverflow.com/questions/12737860/…Joe

1 Answers

0
votes

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!