0

I'm trying to create a publisher for CoreData changes.

I've implemented Publisher protocol and I was required to implement NSFetchedResultsControllerDelegate in same type (not in extension).

Next, I need to implement different NSFetchedResultsControllerDelegate methods for different Outputs.

But when I add constraint where to method, xcode tells that it is not protocol method but "nearly matches optional requirement" and this method not called.

func controllerDidChangeContent(_ controller: NSFetchedResultsController<NSFetchRequestResult>) 
    where Output == [T]
{

}

func controller(
    _ controller: NSFetchedResultsController<NSFetchRequestResult>,
    didChangeContentWith snapshot: NSDiffableDataSourceSnapshotReference)
    where Output == PublishedSnapshot
{

}

enter image description here enter image description here

I can't implement both methods without any conditions because ```controller(:didChangeContentWith) hides all other delegate methods.

What should I do to implement different methods depending on Output type?

Alexey
  • 79
  • 7
  • Why do you need different delegate methods for different Output types? – Joakim Danielson Apr 27 '22 at 20:43
  • @JoakimDanielson, because "I can't implement both methods without any conditions because ```controller(:didChangeContentWith) hides all other delegate methods." – Alexey Apr 28 '22 at 12:10

0 Answers0