NSFetchedResultsController delegate keeps getting .Move change type instead of .Update

Originator:john.rommel.estropia
Number:rdar://22380191 Date Originated:
Status:Open Resolved:
Product:Developer Tools Product Version:XCode 7 beta 5
Classification:Serious Bug Reproducible:Always
 
Summary:
Related thread: https://forums.developer.apple.com/thread/4999

I am the developer of a Core Data wrapper library called CoreStore:
https://github.com/JohnEstropia/CoreStore
The bug I am reporting can be reproduced with the library's demo app.

One of the utilities the library provides, "ObjectMonitor.swift", is a wrapper on NSFetchedResultsController that observes just a single NSManagedObject by fetching with:
NSPredicate("SELF == %@", managedObjectID)

This worked well until XCode 6.4. Starting XCode 7 (I'm not sure which beta) though, the NSFetchedResultsControllerDelegate method "controller(_:didChangeObject:atIndexPath:forChangeType:newIndexPath)"  keeps getting erratic notifications on iOS 9 simulator where the change type is always ".Move from index 0 to index 0", instead of an .Update type.

On all iOS versions, another problem can be reproduced with "ListMonitor.swift", an NSFetchedResultsController wrapper that observes a list. Because of the ".Move from index 0 to index 0" delegate calls, this crashes and breaks UITableViews that call beginUpdates() and endUpdates() because no actual changes occurred.

Steps to Reproduce:
Sample 1:
1. Run the CoreStoreDemo app using any simulator/device
2. Choose the "Colors" demo
3. Add some colors using the + button
4. From the top list, tap the first color
5. Drag the hue slider back and forth. This should update the list at bottom half of the screen.
6. After a while the UITableView will crash due to the NSFetchedResultsControllerDelegate receiving Move(0-0) calls instead of Update calls, which causes missing updates in between UITableView.beginUpdates() and UITableView.endUpdates().

Sample 2:
1. Run the CoreStoreDemo app on an iOS 8.4 or below simulator/device
2. Choose the "Colors" demo
3. Add some colors using the + button
4. From the top list, tap the first color
5. From the bottom list, tap the exact same color as the top
6. Drag any of the sliders. This correctly updates both top and bottom.
7. Repeat steps 1-6, this time by running the CoreStoreDemo app on an iOS 9 simulator/device. Dragging the sliders do not cause any updates due to the NSFetchedResultsControllerDelegate receiving Move calls instead of Update calls.

Expected Results:
- Updates should report .Update type, not .Move type
- There should be no .Move events with source NSIndexPath equal to the destination NSIndexPath


Actual Results:
Sample1:
- UITableView crashes with an assertion failure

Sample2:
- Updates do not reach the NSFetchedResultsController

Version:
XCode 7 beta 5

Notes:


Configuration:
Any simulator or device

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!