'SwiftUI: Cannot convert value of type 'Float' to expected argument type '()'
I'm trying to create rows of Textfields and then store the user's input to a dictionary.
@Binding var numPeople: Int
@State var dict: [String : Float] = [:]
@State var name: String = ""
@State var amount: Float = 0.00
.
.
.
ForEach(1...numPeople, id:\.self) { stack in
HStack {
TextField("Name", text: $name)
.padding()
Text("Amount in $:")
TextField("", value: $amount, formatter: NumberFormatter())
.keyboardType(.numberPad)
.onReceive(Just(amount)) { // I do have Combine imported
dict[name] = amount
}
.padding()
}
}
But it seems to not work, and I can't figure out why (I'm pretty new to this language). I even checked for an empty VStack, HStack, etc. All I have is Cannot convert value of type 'Float' to expected argument type '()'.
Thank you!
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|
