I'm trying to get used to the MVVM-Pattern in swift. So I was coding around a bit and I get this error again and again:
The compiler is unable to type-check this expression in reasonable time; try breaking up the expression into distinct sub-expressions
I read a lot here, and i know that breaking up the code in smaller peaces would help - but with SwiftUI, I mean, thats pretty difficult, cause the code I wrote is just how it should be using SwiftUI (correct me if I'm wrong).
So, I'm pretty frustrated right now, trying to get this to work. Maybe anybody has an idea?
Here is a screenshot:
And the code:
import SwiftUI
struct ContentView: View {
var modelPizza = PizzaModel()
var body: some View {
NavigationView {
List(modelPizza.pizzas) { p in
NavigationLink(
destination:
Text("Destination"),
label: {
VStack(alignment: .leading) {
Text(p.name)
.font(.title)
HStack {
Text(p.toping1)
.italic()
Text(p.toping2)
.italic()
Text(p.toping3)
.italic()
}
}
})
}.navigationTitle("Pizzas")
Button(action: {
print("Hello")
}, label:
Text("Hello")
)
}
}
}
struct ContentView_Previews: PreviewProvider {
static var previews: some View {
ContentView()
}
}
Would love to hear from you - Thanks in advance.
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…