I have a standard view of the main parts table with menu . The menu works, but for some reason I get the following error when I press the + button to add another cell to my application:
The application terminated due to the unannounced exception "NSInternalInconsistencyException", reason: "could not delete the cell with the identifier Cell - either register either a class for the identifier or connect the prototype cell in the storyboard"
I was looking for a solution for days
If I add to viewDidLoad :
[self.tableView registerClass:[UITableViewCell class] forCellReuseIdentifier:cellIdentifier];
I am not getting an error, but the added cells are not the ones that are configured in my storyboard, and do not point to the detailed view controller.
I checked several times if the identifier field for the prototype cell was filled in and matches * cellIdentifier.
From what I know, it looks like the same character as the question here .
Any help would be appreciated, and if you have the time, explain why this is wrong, what I did or why you need to add code.
Requested code (both codes added by Xcode 5.0.1 by default):
// Code to add the button UIBarButtonItem *addButton = [[UIBarButtonItem alloc] initWithBarButtonSystemItem:UIBarButtonSystemItemAdd target:self action:@selector(insertNewObject:)]; self.navigationItem.rightBarButtonItem = addButton; // Code called when button is pressed: - (void)insertNewObject:(id)sender { if (!_objects) { _objects = [[NSMutableArray alloc] init]; } [_objects insertObject:[NSDate date] atIndex:0]; NSIndexPath *indexPath = [NSIndexPath indexPathForRow:0 inSection:0]; [self.tableView insertRowsAtIndexPaths:@[indexPath] withRowAnimation:UITableViewRowAnimationAutomatic]; } } - (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath { UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:cellIdentifier forIndexPath:indexPath]; NSDate *object = _objects[indexPath.row]; cell.textLabel.text = [object description]; return cell; }
Also check out the photos and project files added to the comment.
source share