-1

我有这个因错误而崩溃的代码*** Terminating app due to uncaught exception 'NSRangeException', reason: '*** -[NSArray objectAtIndex:]: index 0 beyond bounds for empty array'

在这一行:

- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
    MyObject *myCode = [self.fetchedResultsController objectAtIndexPath:indexPath];
}

我看不出这里有什么问题,它正在从获取中提取数据。

4

1 回答 1

4

答案就在你的帖子里'reason: ' ... index 0 beyond bounds for empty array'。您self.fetchedResultsController现在是空的,您需要调查原因。

注意:每当您修改表视图的基础数据时,您需要通过调用-[UITableView reloadData];beginUpdatesandendUpdates方法来更新更改,然后添加或删除正确的索引路径。

于 2011-09-07T20:34:13.193 回答