Note that there are some explanatory texts on larger screens.

plurals
  1. POiOS app crash connected with iCloud
    primarykey
    data
    text
    <p>My app uses just one <code>managedObjectContext</code> and is set up to sync coredata changes with iCloud, and I'm using <code>NSFetchedResultsController</code> to fetch data for my <code>UITableView</code>. The problem occurs when I try to edit (reorder) the table cells.</p> <p>Imagine this scenario:</p> <p>I execute <code>[tableView setEditing:YES animated:YES];</code><br> I hold down my finger on a row, and start to move it around the <code>tableView</code> (reorder). In the meantime I delete a row in the mac app, and save the changes.</p> <p>iOS app gets to know about the new changes and my <code>fetchedResultsController</code> tries to call <code>[tableView beginUpdates]</code> ... and remove the row from the <code>tableView</code> while it's being edited.</p> <p>I don't know if it should work this way, but it crashes.</p> <p>How would you try to solve this?</p> <p>Log:</p> <pre><code>***[3758:707] asynchronously added persistent store! ***[3758:707] numberOfRowsInSection:3 ***[3758:707] numberOfRowsInSection:2 ***[3758:707] *** Assertion failure in -[UITableView _endCellAnimationsWithContext:], /SourceCache/UIKit/UIKit-1912.3/UITableView.m:1046 ***[3758:707] CoreData: error: Serious application error. An exception was caught from the delegate of NSFetchedResultsController during a call to -controllerDidChangeContent:. Invalid update: invalid number of rows in section 0. The number of rows contained in an existing section after the update (3) must be equal to the number of rows contained in that section before the update (3), plus or minus the number of rows inserted or deleted from that section (0 inserted, 1 deleted) and plus or minus the number of rows moved into or out of that section (0 moved in, 0 moved out). with userInfo (null) ***[3758:707] *** Terminating app due to uncaught exception 'NSRangeException', reason: '*** -[__NSArrayM insertObject:atIndex:]: index 2 beyond bounds [0 .. 0]' </code></pre> <p>The first two logs are in the - (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section method and log what i'm returning. I found out that the first time I returned 3, and the second time it was 2!</p> <p>EDIT: And now im thinking ... should it work this way, or I have to find another way to make it ? What should happen when you're dragging a cell, and call [tableView moveRowAtIndexPath:toIndexPath:]; ?</p>
    singulars
    1. This table or related slice is empty.
    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.
 

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