HI Everyone, I’m currently following the IOS foundation Course (Module 4 lesson 11)
And I have this Error : The compiler is unable to type-check this expression in reasonable time; try breaking up the expression into distinct sub-expressions
within this code:
struct RecipeDetailView: View
{
var recipe:Recipe
@State var selectedServiceSize = 2
var body: some View
{
ScrollView
{
VStack(aligment: .leading)
{
// MARK: Recipe Image
Image(recipe.image)
.resizable()
.scaledToFill()
// MARK: Serving Size Picker
VStack(alignment: .leading)
{
Text("Select your serving size: ")
Picker("", selection: $selectedServiceSize)
{
Text("2").tag(2)
Text("4").tag(4)
Text("6").tag(6)
Text("8").tag(8)
}.pickerStyle(SegmentedPickerStyle())
.frame(width: 160)
}
// MARK: Ingredients
VStack(alignment: .leading)
{
Text("Ingredients")
.font(.headline)
.padding(.vertical, 5)
ForEach(recipe.ingredients)
{ ingredient in
Text("- " + ingredient.name)
}
}.padding(.horizontal)
// MARK: Divider
Divider()
// MARK: Directions
VStack(alignment: .leading)
{
Text("Directions")
.font(.headline)
.padding(.vertical, 5)
ForEach(0..<recipe.directions.count, id: \.self)
{ index in
Text(String(index + 1) + " - " + recipe.directions[index])
.padding(.bottom, 5)
}
}
}
}.navigationBarTitle(recipe.name)
}
}
I tried a few things including rewriting it and copy words for words Chris’s code but the same problem occurs even when I try to copy paste his file content
Did someone has the same problem?
Thanks in advance