NSFetchedResultsController reports some updates incorrectly if app is built using Xcode 7A152u

Originator:Bernhard.Loibl
Number:rdar://22796598 Date Originated:22-Sep-2015 09:07 AM
Status:Open Resolved:
Product:iOS SDK Product Version:iOS 9 beta 3 (13A4293g)
Classification:Serious Bug Reproducible:Always
 
This is a duplicate of rdar://21888197

Summary:
An iOS app uses Core Data with the following configuration:
– One entity with one string attribute ("name") and one boolean attribute ("flag").
– Two managed object context connected to the same persistent store coordinator: the "main" context, created initially, and "auxiliary" context created on demand. Both contexts use main queue concurrency type for simplicity.
– NSFetchedResultsController with a fetch request that fetches instances of that entity and orders them by "name", connected to "main" context.
– Saves on "auxiliary" context are merged into the "main" context via mergeChangesFromContextDidSaveNotification method.

When building this app using Xcode 7A152u (Xcode 7 beta 3) and running either iOS 9 beta 3 or iOS 8.4, changing the "flag" attribute on an object in "auxiliary" context, saving and merging this change into the "main" context results in fetch results controller reporting a NSFetchedResultsChangeMove with "old" index path equal to the "new" index path. This does not happen if building using Xcode 6.4 and running either iOS 8.4 or iOS 9 beta 3.

Steps to Reproduce:
1. Build an app using the description above (sample app attached).
2. Create objects on "main" context with names: "Object A", "Object B", "Object C", and save the changes.
3. Create an "auxiliary" context; fetch object with name "Object A" in that context, and change its "flag" attribute to anything.
4. Save this "auxiliary" context.
5. Save notification from "auxiliary" context is merged into "main" context.
6. Fetched results controller responds to the merge.

Expected Results:
Fetch results controller reports only update (NSFetchedResultsChangeUpdate) of the object with name "Object A", at index path (0,0).

Actual Results:
Fetch results controller reports an update of "Object A", but also a move (NSFetchedResultsChangeMove) from index path (0,0) to index path (0,0) of that same object, even though it didn't change its name (which affects the order in fetched results controller). A move from one index path to that same index path doesn't make sense.

Version:
iOS 9 beta 3 (13A4293g) or iOS 8.4 (12H143), this seems to be unrelated.

Notes:
Noting again: the issue seems to be caused either by Xcode 7 beta 3 (7A152u) or iOS 9 beta 3 SDK, since it also happens on iOS 8.4, while building the same app using Xcode 6.4 (6E35b) does not manifest the issue on either iOS 8.4 or iOS 9 beta 3.

Configuration:
Any hardware or simulator.

Attachments:
'FRCUpdateDemo.zip' was successfully uploaded.
(available on GitHub: https://github.com/vlas-voloshin/FRCUpdateBugDemo)

Comments

iOS9 SDK issue

We have encountered same issue building application using iOS9 SDK. Our temporary workaround is to detect if indexePath are same for this NSFetchedResultsChangeMove. If this is a case we cover this to NSFetchedResultsChangeUpdate.

By lwarchol87 at Oct. 21, 2015, 12:05 p.m. (reply...)

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!