'Bool' is not convertible to 'Binding<Bool>'

I have a swiftUI native Watch app I Am working on. I have a combine based class that allows me to store userdefaults, one of which is a simple toggle ..

import SwiftUI
import Foundation
import Combine


class MeetingSetup: BindableObject {
    
    let willChange = PassthroughSubject<Void, Never>()
    
    var twitterEnabled: Bool = false {
        didSet {
            willChange.send()
        }
    }
    
    init() {
        
        let prefs:UserDefaults = UserDefaults(suiteName: "group.com.appname")!
        
        twitterEnabled = prefs.bool(forKey: "keyTwitterEnabledBool")

    }
    
    
}


In the SwiftUI I am getting the error messages that 'Bool' is not convertible to 'Binding<Bool>'

import SwiftUI
import Combine

struct SetupView : View {
    
    @ObjectBinding var meetingSetup: MeetingSetup = delegate.meetingSetup
    
    var body: some View {
       
                HStack{
                    Toggle(isOn: self.meetingSetup.twitterEnabled){  // <== 'Bool' in not convertible to 'Binding<Bool>'
                        Text("Twitter")
                    }
    }
}

I don't understand why this is getting the message since the code is @ObjectBinding, should it not be 'Binding<Bool>' by definition? If not how do I address this correctly??

Accepted Reply

Hi,


Change


Toggle(isOn: self.meetingSetup.twitterEnabled)


to


Toggle(isOn: $meetingSetup.twitterEnabled)

Replies

Hi,


Change


Toggle(isOn: self.meetingSetup.twitterEnabled)


to


Toggle(isOn: $meetingSetup.twitterEnabled)