I am currently migrating an app from the classic UITableViewDataSource to UITableViewDiffableDataSource. In certain complex cases, I find myself needing to toggle between the UITableViewDataSource and UITableViewDiffableDataSource on a single UITableView instance.
Apple's official documentation for UITableViewDiffableDataSource contains a strict warning: "Do not change the dataSource on the table view after you configure it with a diffable data source. If the table view needs a new data source after you configure it initially, create and configure a new table view and diffable data source."
I’m seeking clarification on:
- Internal State: What specific UIKit caching or internal state is corrupted if we nil out the diffable source and re-assign a classic one?
- Background Processes: Does the background diffing engine pose a risk (race conditions/crashes) if the source is swapped while a diff is calculating?
- The "Safe" Reset: If swapping is truly necessary, is there a verified cleanup sequence (e.g., clearing snapshots first) that avoids the need to recreate the UITableView entirely?