可以将约束添加到方法
我正在尝试为Coredata更改创建出版商。
我已经实施了发布者协议,因此我被要求以同一类型实现NSfetchedResultScontrollerDelegate(不扩展)。
接下来,我需要为不同的输出实现不同的NSFetchedResultScontrollerDelegate方法。
但是,当我将约束添加到方法中时,Xcode告诉它不是协议方法,而是“几乎匹配可选要求”,并且此方法未调用。
func controllerDidChangeContent(_ controller: NSFetchedResultsController<NSFetchRequestResult>)
where Output == [T]
{
}
func controller(
_ controller: NSFetchedResultsController<NSFetchRequestResult>,
didChangeContentWith snapshot: NSDiffableDataSourceSnapshotReference)
where Output == PublishedSnapshot
{
}
我无法在没有任何条件的情况下实现这两种方法,因为``````controller(:didchangecontent with)掩盖了所有其他委托方法。
根据输出类型,我该怎么做才能实现不同的方法?
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
{
}
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?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论