NSFetchedResultsController不更新UITableView的节索引

Lut*_*ker 4 iphone core-data uitableview nsfetchedresultscontroller

我正在使用NSFetchedResultsController填充UITableViewController,其中结果创建了用于填充节标题和节索引的节.我使用以下方法填充节索引:

- (NSArray *)sectionIndexTitlesForTableView:(UITableView *)tableView {
    return [fetchedResultsController_ sectionIndexTitles];
}
Run Code Online (Sandbox Code Playgroud)

现在我遇到了一个问题.当我向与NSFetchedResultsController关联的NSManagedObjectContext添加新元素时,新元素将被保存并在UITableView中适当地显示为单元格...除了一件事.如果新元素创建了一个新的SECTION,则除了弹出UINavigationController的堆栈并重新加载UITableViewController之外,新的section索引不会显示在右边距中.

我已经符合NSFetchedResultsControllerDelegate的接口并手动调用

[self.tableView reloadSectionIndexTitles];
Run Code Online (Sandbox Code Playgroud)

在这两个委托方法的最后:

controller:didChangeSection... 
controller:didChangeObject...
Run Code Online (Sandbox Code Playgroud)

虽然我可以调试并跟踪执行到方法中并查看调用的重载调用,但UITableView的节索引从不反映节的更改.

同样,数据显示 - UITableView中的新部分在物理上可见(或删除),但部分索引未更新.

我错过了什么吗?

Sim*_*ide 7

看起来这是我们都有的错误.请参阅http://iphonedevelopment.blogspot.com/2009/11/i-know-youre-tired-of-hearing-about.html,看起来像是一个相当讨厌的太多行代码解决方案.我跟着这个:

- (void)viewWillAppear:(BOOL)animated; {
  // This is a dumb hack required by this bug: http://iphonedevelopment.blogspot.com/2009/11/i-know-youre-tired-of-hearing-about.html
  [self.tableView reloadData];
}
Run Code Online (Sandbox Code Playgroud)

这可能是低效的,但除非你有大量的数据,否则它可能不会造成任何伤害.它只有一行代码.因此,当apple修复他们的bug时,你可以轻松地将其删除.