Add reconfigureItems support for FetchedResultsController

Originator:indiekiduk
Number:rdar://FB9206296 Date Originated:24 Jun 2021
Status:Open Resolved:No
Product:Core Data Product Version:Xcode 13b1
Classification:Suggestion Reproducible:
 
Please see another feedback FB9174006 making the same request but was submitted to the UIKit team.

In Xcode 13b1, UIDiffableDataSource.h has a new reconfigureItems method (see below). It would be great if this could be used in the NSFetchedResultsController snapshot API to replace reloadItems. 

In my experience reloading a cell when the NSManagedObject has been updated causes all kinds of visual glitches and bugs. E.g. if a user has swiped on a cell that is backed by a managed object that is updated, when the snapshot is used to update the table the cell jumps back to not being swiped. A similar issue happens if a cell was previously selected when the update happened. 

I have not tested it but it sounds to me like this reconfigureItems method could resolve all of these problems. I am aware though that it is possible when a managed object changes, someone might actually want to use a different cell entirely to display the updated object. I hope you can come up with a good solution to support both uses cases!

// Reconfigures any existing cells for the items. Reconfiguring is more efficient than reloading an item, as it does not replace the
// existing cell with a new cell. Prefer reconfiguring over reloading unless you actually need an entirely new cell for the item.
- (void)reconfigureItemsWithIdentifiers:(NSArray<ItemIdentifierType>*)identifiers API_AVAILABLE(ios(15.0), tvos(15.0));

I also really would like a method on NSFetchedResultsController to retrieve the current snapshot that I can apply to the table after the first performFetch without animation. Because it calls the delegate method for the first fetch and any updates, I have the inconvenience of needing to track if it is the first call so I can apply the update to the table without animation. However I am also experimenting with checking if the window handle is valid instead of using my own bool for that.

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!