With Xcode 7 Beta 1-3, NSFetchedResultsController gives insert event instead of update events
| Originator: | dayrobertj | ||
| Number: | rdar://21779132 | Date Originated: | 7/10/2015 |
| Status: | Open | Resolved: | |
| Product: | iOS | Product Version: | Xcode 7 Beta, iOS 8.4 |
| Classification: | Serious Bug | Reproducible: | Always |
Summary: When modifying an object that is being managed by a fetched results controller, the FRC sends a delegate message saying that an insert event occurs. This creates an assertion: 2015-07-10 23:04:12.959 BrokenSwift[254:23658] *** Assertion failure in -[UICollectionView _endItemAnimationsWithInvalidationContext:tentativelyForReordering:], /SourceCache/UIKit/UIKit-3347.44.2/UICollectionView.m:4072 with a specific error: 2015-07-10 23:11:19.126 BrokenSwift[261:24842] CoreData: error: Serious application error. An exception was caught from the delegate of NSFetchedResultsController during a call to -controllerDidChangeContent:. Invalid update: invalid number of items in section 0. The number of items contained in an existing section after the update (2) must be equal to the number of items contained in that section before the update (2), plus or minus the number of items inserted or deleted from that section (1 inserted, 0 deleted) and plus or minus the number of items moved into or out of that section (0 moved in, 0 moved out). with userInfo (null) This happens when running in Xcode 7 beta 1, 2, and 3 on an iOS 8.3 and iOS 8.4 physical device (it doesn't happen in the simulator). I've tested on both an iPhone 5 and an iPhone 6 Plus. This bug does NOT happen on a device running iOS 9. Steps to Reproduce: I have included a sample project. Run it on a physical phone running iOS 8. Once it loads, hit the add bar button item (this populates some sample data). Then, hit the change button. You will see the assert occur. The change button simply takes the model object bound to the first collection view cell and changes one field's value. Expected Results: I expect to get an update event. Actual Results: I get an insert event Version: iOS 8.4 (12H143) Notes: As noted, this only happens on physical devices, not in the simulator. Configuration: iPhone 5 32 gig Verizon, wifi; iPhone 6 plus 64 gig Verizon, wifi
Comments
Please note: Reports posted here will not necessarily be seen by Apple. All problems should be submitted at bugreport.apple.com before they are posted here. Please only post information for Radars that you have filed yourself, and please do not include Apple confidential information in your posts. Thank you!