UITableView dataSource must return a cell from tableView:cellForRowAtIndexPathが出た時
UITableViewを使っている時に以下のエラーが発生したのでメモ。
[エラー内容]
[UITableView _createPreparedCellForGlobalRow:withIndexPath:], /SourceCache/UIKit/UIKit-1914.85/UITableView.m:6061
2012-06-24 19:13:41.460 Yarukoto[3083:707] *** Terminating app due to uncaught exception 'NSInternalInconsistencyException', reason: 'UITableView dataSource must return a cell from tableView:cellForRowAtIndexPath:'
これはStoryBoard上で作成した「UITableViewCell」の「Identifier」と、
そのUITableViewControllerに紐ずくクラスのコード中の「Identifer」が異なると発生するみたいです。
なのでそもそも以下のコードがないと発生します。
そしてCellIdentifier = @"Cell";の@"Cell"の所がStoryBoardで設定した「Identifier」と一緒でないとだめです。
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath { static NSString *CellIdentifier = @"Cell"; UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier]; // Configure the cell... return cell; }