Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>I just ran into a crash on update, and it appears that the <code>newIndexPath</code> is provided as an index path into the fetched results controller objects when that index path does not match the index path needed to retrieve the cell from the table. Consider the following:</p> <ol> <li>A table view has a section at index 0 with 15 items.</li> <li>The item at index 13 (the second-to-last item) is deleted</li> <li>The item at index 14 (the last item) is updated</li> </ol> <p>In the above case, assuming that you are using <code>[tableView beginUpdates]</code> and <code>[tableView endUpdates]</code> in the appropriate <code>controllerWill/DidChangeContent:</code> methods, you will need to use the <code>indexPath</code> parameter to retrieve the cell from the table to update (which will be section 0, index 14) and the <code>newIndexPath</code> parameter to retrieve the object to configure the cell with from the results controller (which will be section 0, index 13).</p> <p>I assume it works this way because the delete seems to have already happened as far as the results controller is concerned, but has not happened in the table view (due to the <code>beginUpdates/endUpdates</code> calls wrapping the updates). It makes some sense if you consider the above case, but it seems that all of the documentation does not consider this case.</p> <p>So the answer to the question is that it appears that you should use the <code>indexPath</code>parameter to retrieve a cell from the table view, and the <code>newIndexPath</code> parameter to retrieve the object from the fetched results controller. Note that if there has not been an insert or delete it appears to pass <code>nil</code> for <code>newIndexPath</code>, so in this case you would have to use <code>indexPath</code> for both purposes.</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload