views:

54

answers:

2

Hello,

I have a UITableView displaying an underlying NSFetchedResultsController.

When the fetchedResultsController is updated,

- (void)controller:(NSFetchedResultsController *)controller didChangeObject:(id)anObject atIndexPath:(NSIndexPath *)indexPath forChangeType:(NSFetchedResultsChangeType)type newIndexPath:(NSIndexPath *)newIndexPath {

is called. And the following is executed:

  case NSFetchedResultsChangeInsert:
   [tableView insertRowsAtIndexPaths:[NSArray arrayWithObject:shiftedIndexPath] withRowAnimation:UITableViewRowAnimationFade];
   break;

The cellForRowAtIndexPath is only called for the new line (which is logical)

The problem is however that all the values displayed in the rows of the table view are shifted down. The first row displays its title. The second rows displays the first row's title. The third row the second row's title etc. If I repeat that, the third row will display the second's row title, the fourth the third row's title etc.

I don't understand what can happen, especially because cellForRowAtIndexPath is only called for the new line (which is logical) and not for all these lines. Additionally, if I click on these lines which have the wrong title, it opens the right document (didSelectRowAtIndexPath works correctly with the indexPath)

Any clue of what could happen? Thanks!

A: 

What is the code that is causing the delegate methods to get called? Please edit your answer and add in that code so that we can see the full lifecycle of this event.

Marcus S. Zarra
A: 

Ill say, if your change needs to put an impact on all the rows available in TableView, than you definitely needs to call [tableView reloadData]

Ansari
No, my change just inserts a new line into the core data model.
Kamchatka