I'm getting a Expression type 'Binding<_>' is ambiguous without more context error at $order.quantity.contracts
in the following code:
struct ContractsPickerView: View {
@Binding var order: Order
var question: String
var body: some View {
Error
|
|
V
Picker(selection: $order.quantity.contracts, label: Text("\(question)").font(.headline)) {
ForEach(0..<101, id: \.self) { contracts in
Text("\(contracts)")
}
}
}
}
In fact, Xcode is not offering me the contracts
attribute in the Quantity
class after typing $order.quantity.
. Here are the models:
struct Order {
var quantity: Quantity?
}
struct Quantity: Hashable {
private var userEnteredContracts: Int?
var contracts: Int {
get {
return userEnteredContracts
}
set(newContracts) {
userEnteredContracts = newContracts
}
}
}
Can somebody explain the issue and offer a solution please?