Fist problem is that
func detailLine(costa: inout [Double], tipa: inout [Double]) {
is never called
how should it get costa and tips ?
When do you want to call ?
When you tap Detail ?
If so, here is the fix, but I do not understand the logic here:
struct ViewDetail: View {
@State var text1: String = ""
@State var tip1: String = ""
@State var text23: String = ""
@State var tip23: String = ""
var body: some View {
HStack {
Text(text1)
Text(tip1)
Text(text23)
Text(tip23)
}
.onAppear {
text1 = "125"
}
}
func detailLine(costa: inout [Double], tipa: inout [Double]) { // NEVER Called
print(costa, tipa)
text1 = "125"
print("detail")
}
}
Second problem
How do you want to use text1 in ContentView ? It never appears.
If you want, here is how to do with Binding
Thrid problem in:
func delete(costa: inout [Double], tipa: inout [Double], number: inout Int) {
print(costa, tipa)
tipa.removeLast() // Crash here as tipa is empty
There is a simple fix:
func delete(costa: inout [Double], tipa: inout [Double], number: inout Int) {
print(costa, tipa)
if !tipa.isEmpty && !costa.isEmpty {
tipa.removeLast()
costa.removeLast()
number -= 1
}
print(costa,tipa)
}
The complete code in next post.
Topic:
Developer Tools & Services
SubTopic:
Xcode