0

Using NSFetchedResultsController delegate method controller (_:didChange: at:for:newIndexPath:), between tableView.beginUpdates() in controllerWillChangeContent(_:) and tableView.endUpdates() in controllerDidChangeContent(_:), results in objects with nil properties (including the uniqueIdentifier, which is normally set in awakeFromInsert()) being created when merging changes from different devices, and related crash. The problem doesn't occur when only the controllerDidChangeContent(_:) delegate method with tableView.reloadData() is implemented instead.

Any advice on how to eliminate this problem would be appreciated.

Maor
  • 3,340
  • 3
  • 29
  • 38
fivewood
  • 391
  • 4
  • 11

1 Answers1

0

Adding tableView.reloadData() in controllerWillChangeContent(_:) just before beginUpdates() seems to solve the problem. It ensures that data in the tableView is in sync with that in the fetchedResultsController (FRC) before the tableView is modified by the FRC delegate methods.

fivewood
  • 391
  • 4
  • 11