Skip to content

Instantly share code, notes, and snippets.

@laevandus
Created March 31, 2023 03:42
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save laevandus/6df29a6929b8835ef7c1b10259da55f1 to your computer and use it in GitHub Desktop.
Save laevandus/6df29a6929b8835ef7c1b10259da55f1 to your computer and use it in GitHub Desktop.
private final class FetchedResultsObserver<Result: NSManagedObject>: NSObject, NSFetchedResultsControllerDelegate {
var willChange: () -> Void = {}
var didChange: () -> Void = {}
init(controller: NSFetchedResultsController<Result>) {
super.init()
controller.delegate = self
}
func controllerWillChangeContent(_ controller: NSFetchedResultsController<NSFetchRequestResult>) {
willChange()
}
func controllerDidChangeContent(_ controller: NSFetchedResultsController<NSFetchRequestResult>) {
didChange()
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment