我已经创建了Publisher协议和该结构,但是却收到一条错误消息,指出该结构不符合协议Publisher。我需要对结构添加哪些代码?
我尝试添加推荐的存根,但是我一直收到错误消息。
import SwiftUI
import Combine
protocol Publisher
{
associatedtype Output
associatedtype Failure: Error
func subscribe<S: Subscriber>(_ subscriber: S)
where S.Input == Output, S.Failure == Failure
}
extension NotificationCenter
{
struct Publisher: Combine.Publisher
{
typealias Output = Notification
typealias Failure = Never
init(center: NotificationCenter, name: Notification.Name, object: Any? = nil)
}
}
我应该能够简单地运行该程序。