Issues with Core Data Fetching Performance on iOS 16 with NSFetchedResultsController
I'm attempting to set up I'm experiencing significant performance issues when using `NSFetchedResultsController` for fetching data in my iOS 16 application. The app is structured to display a list of items in a `UITableView`, and I have set up the fetched results controller to monitor changes in the data. However, when the underlying data changes, the updates to the `UITableView` are taking far too long, causing noticeable lag and unresponsiveness. I've set up my `NSFetchedResultsController` like this: ```swift let fetchRequest: NSFetchRequest<Item> = Item.fetchRequest() fetchRequest.sortDescriptors = [NSSortDescriptor(key: "name", ascending: true)] self.fetchedResultsController = NSFetchedResultsController(fetchRequest: fetchRequest, managedObjectContext: context, sectionNameKeyPath: nil, cacheName: nil) self.fetchedResultsController.delegate = self ``` In the delegate methods, I'm only reloading the affected sections or rows, like so: ```swift func controller(_ controller: NSFetchedResultsController<NSFetchRequestResult>, didChange anObject: Any, at indexPath: IndexPath?, for type: NSFetchedResultsChangeType, newIndexPath: IndexPath?) { switch type { case .insert: if let newIndexPath = newIndexPath { tableView.insertRows(at: [newIndexPath], with: .automatic) } case .delete: if let indexPath = indexPath { tableView.deleteRows(at: [indexPath], with: .automatic) } case .update: if let indexPath = indexPath { tableView.reloadRows(at: [indexPath], with: .automatic) } case .move: if let indexPath = indexPath, let newIndexPath = newIndexPath { tableView.moveRow(at: indexPath, to: newIndexPath) } } } ``` I've also tried to use batch updates, but the performance is still not optimal, especially when there are many changes at once. When this happens, the app freezes momentarily, and I see the following warning in the console: "Warning: Attempt to present on <UIViewController> while a presentation is in progress." I've checked the data model for any issues and ensured that the context is properly managed. I'm not sure if this is due to the number of changes being processed at once or if there's something fundamentally wrong with how I'm implementing `NSFetchedResultsController`. Has anyone encountered similar issues, and what strategies can I use to improve performance?