Closed yonat closed 5 years ago
It seems controller(:, didChange:, atSectionIndex:, for:)
doesn't get called at all. Only controller(:, didChange:, at:, for:, newIndexPath:)
gets called for each object with type == .update
.
So maybe it would be a good idea to check if newIndexPath != indexPath
?
I created a minimal project that reproduces the crash at https://github.com/yonat/DATASourceSectionBug .
The crash-causing code is at https://github.com/yonat/DATASourceSectionBug/blob/d1977b5fe68f33bf02e9c476433f9c5ca3731c5c/SectionBug/AppDelegate.swift#L26
The crash is avoided if I remove the workaround here: https://github.com/3lvis/DATASource/blob/cf5e9a83264ea00ab64cb7ef44c70aa7d1666aad/Source/DATASource%2BNSFetchedResultsControllerDelegate.swift#L82
I'm seeing similar problems in one of our apps. But so far I have not been able to reproduce the crash. We updated from version 7.2.0 to 7.4.0 and are still seeing crashes. I wonder if the problem is related to the one described in this issue at all.
This is what I found in the Firebase traces:
Fatal Exception: NSInternalInconsistencyException 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 (0), plus or minus the number of rows inserted or deleted from that section (0 inserted, 0 deleted) and plus or minus the number of rows moved into or out of that section (0 moved in, 0 moved out).
Just wanted to share that in my new projects, I've been moving away from Core Data and it has improved the clarity of my code.
Hi @3lvis and thanks for such a useful library!
I have a crash that occurs rarely, I think it's related for an object moving from one section to another, causing a certain section to be removed or inserted.
I have 4
Session
objects, sorted to sections byphase
, and when one of them changes phase I get a crash:Any idea what might be going on?
The errors:
Assertion failure in -[UITableView _Bug_Detected_In_Client_Of_UITableView_Invalid_Number_Of_Rows_In_Section:], /BuildRoot/Library/Caches/com.apple.xbs/Sources/UIKitCore_Sim/UIKit-3899.22.15/UITableView.m:2401 [error] fault: 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 (2) must be equal to the number of rows contained in that section before the update (1), plus or minus the number of rows inserted or deleted from that section (0 inserted, 0 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) CoreData: fault: 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 (2) must be equal to the number of rows contained in that section before the update (1), plus or minus the number of rows inserted or deleted from that section (0 inserted, 0 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) [error] CoreData: 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 (2) must be equal to the number of rows contained in that section before the update (1), plus or minus the number of rows inserted or deleted from that section (0 inserted, 0 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) [error] error: Serious application error. Exception was caught during Core Data change processing. This is usually a bug within an observer of NSManagedObjectContextObjectsDidChangeNotification. Invalid update: invalid number of rows in section 0. The number of rows contained in an existing section after the update (2) must be equal to the number of rows contained in that section before the update (1), plus or minus the number of rows inserted or deleted from that section (0 inserted, 0 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) CoreData: error: Serious application error. Exception was caught during Core Data change processing. This is usually a bug within an observer of NSManagedObjectContextObjectsDidChangeNotification. Invalid update: invalid number of rows in section 0. The number of rows contained in an existing section after the update (2) must be equal to the number of rows contained in that section before the update (1), plus or minus the number of rows inserted or deleted from that section (0 inserted, 0 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) Terminating app due to uncaught exception 'NSInternalInconsistencyException', reason: 'Invalid update: invalid number of rows in section 0. The number of rows contained in an existing section after the update (2) must be equal to the number of rows contained in that section before the update (1), plus or minus the number of rows inserted or deleted from that section (0 inserted, 0 deleted) and plus or minus the number of rows moved into or out of that section (0 moved in, 0 moved out).'
Invalid update: invalid number of rows in section 0. The number of rows contained in an existing section after the update (2) must be equal to the number of rows contained in that section before the update (1), plus or minus the number of rows inserted or deleted from that section (0 inserted, 0 deleted) and plus or minus the number of rows moved into or out of that section (0 moved in, 0 moved out).
*** First throw call stack: