I am trying to use ObservableObject to transfer data from a content view to a view controller. so I create all needed code. but at the end I got error'Class ViewController has no initializers'
I don't know where I do wrong, actually I had already initialized them
my error
Class 'KeyboardViewController' has no initializers
1. Stored property 'toggle1' without initial value prevents synthesized initializers
my code
class KeyboardViewController: UIInputViewController {
@Binding var toggle1:Bool
@Binding var toggle2:Bool
@Binding var toggle3:Bool
@Binding var toggle4:Bool
func HiddeTone1Button(containerview: UIStackView){
Tone1Button.isHidden = toggle4
}
and
import SwiftUI
struct ContentView: View {
fileprivate let application = UIApplication.shared
@State private var background1 = Color.gray
@State private var background2 = Color.gray
@State private var background3 = Color.gray
@ObservedObject var TransferData = TranferData()
and
import Combine
final class TranferData: ObservableObject {
@Published var toggle1: Bool = false
@Published var toggle2: Bool = false
@Published var toggle3: Bool = false
@Published var toggle4: Bool = false
}