1. 程式人生 > >iOS Terminating app due to uncaught exception 'NSInternalInconsistencyException', reason: 'unable to

iOS Terminating app due to uncaught exception 'NSInternalInconsistencyException', reason: 'unable to

pop obj bject 位置 ont dex 方法 eid 錯誤

剛接觸iOS,依照教程操作執行出現錯誤

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


解決的方法是加一句:

[self.tableView registerClass:[UITableViewCell class] forCellReuseIdentifier:CellIdentifier];


加的位置是:

- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
static NSString *CellIdentifier = @"ListPrototypeCell";
[self.tableView registerClass:[UITableViewCell class] forCellReuseIdentifier:CellIdentifier];
UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier forIndexPath:indexPath];

// config cell
 XYZToDoItem * toDoItem = [self.toDoItem objectAtIndex:indexPath.row];

cell.textLabel.text = toDoItem.itemName;


return cell;
}

因為剛學習IOS,原因不明

iOS Terminating app due to uncaught exception 'NSInternalInconsistencyException', reason: 'unable to