0

我正在尝试在 UITableView 中删除由 NSFetchedResultsController 管理的对象 - 我正在尝试通过添加/删除按钮从单独的视图中执行此操作。但是,当我在视图之间切换时,控制器和表似乎变得不正常,我无法找出原因。这是我得到的错误 - 不幸的是,它并不总是发生取决于我通过应用程序采取的路径:

严重的应用程序错误。在核心数据更改处理期间捕获到异常:*** -[NSCFArray removeObjectAtIndex:]: index (6) beyond bounds (6) with userInfo (null)

我可以看到我的委托方法被正确调用,删除代码非常简单,我没有看到任何错误。

任何想法/调试提示将不胜感激。

4

2 回答 2

1

我遇到了类似的问题。到目前为止,我发现的唯一解决方案是重新获取 NSFetchedResultsController:

if (![[self resultsController] performFetch:&error]) {
   NSLog(@"%@:%s Error refreshing the fetch controller %@", [self class], _cmd, 
      [error localizedDescription]);
   NSAssert(NO, @"Failed to refresh the fetch controller");
}
于 2010-02-09T05:56:47.873 回答
0

我不确定我们是否有同样的问题,但我的问题已通过以下方式解决:

(NSInteger)numberOfSectionsInTableView:(UITableView *)tableView {
return self.fetchedResultsController.sections.count;}

(NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section {
id <NSFetchedResultsSectionInfo> sectionInfo = [self.fetchedResultsController sections][section];
return [sectionInfo numberOfObjects];}
于 2016-01-09T16:57:34.953 回答