NSFetchedResultsController not updating UITableView's section indexes

Posted by Luther Baker on Stack Overflow See other posts from Stack Overflow or by Luther Baker
Published on 2010-01-03T20:55:02Z Indexed on 2010/03/28 21:43 UTC
Read the original article Hit count: 546

I am populating a UITableViewController with an NSFetchedResultsController with results creating sections that populate section headers and a section index. I am using the following method to populate the section index:

- (NSArray *)sectionIndexTitlesForTableView:(UITableView *)tableView {
    return [fetchedResultsController_ sectionIndexTitles];
}

and now I've run into a problem. When I add a new element to the NSManagedObjectContext associated with the NSFetchedResultsController, the new element is saved and appropriately displayed as a cell in the UITableView ... except for one thing. If the new element creates a new SECTION, the new section index does not show up in the right hand margin unless I pop the UINavigationController's stack and reload the UITableViewController.

I have conformed to the NSFetchedResultsControllerDelegate's interface and manually invoke

[self.tableView reloadSectionIndexTitles];

at the end of both these delegate methods:

controller:didChangeSection... 
controller:didChangeObject...

and while I can debug and trace the execution into the methods and see the reload call invoked, the UITableView's section index never reflects the section changes.

Again, the data shows up - new sections are physically visible (or removed) in the UITableView but the section indexes are not updated.

Am I missing something?

© Stack Overflow or respective owner

Related posts about iphone

Related posts about nsfetchedresultscontrolle