I've been trying to follow the 'Introducing SwiftUI - Building Your First App' WWDC 19 video. No sample code is provided for this talk but I've been creating it as the presenter goes along. When trying to create a store though I get an error that 'Cannot invoke 'send' with no arguments' from the line:
didSet { didChange.send() }
I'm new to programming and struggling to troubleshoot.
import SwiftUI
import Combine
class ReferenceStore : BindableObject {
var references: [Reference] {
didSet { didChange.send() }
}
init(references: [Reference] = []) {
self.references = references
}
var didChange = PassthroughSubject<Void, Never>()
}
I'm using Xcode 11 beta and MacOS Catalina if it helps.
PassthroughSubject<Void, Never>
is your publisher, and it's declared as:
final class PassthroughSubject<Output, Failure> where Failure : Error
And this is send
function:
final func send(_ input: Output)
That means send
needs a Void
argument, which in Swift is the empty tuple ()
.
Replace:
didChange.send()
with
didChange.send(())
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With