Hello guys I have a question regarding this. I was following the course of the iOS Foundations (Module 4 Lesson 6) and coded what Chris did in his video. Still i got this “The compiler is unable to type check …” error. How is this possible ? Do you have any advice for me ? I found a similar thread to this topic but i didnt got the point how to solve it.
Below you can find the code just in case you need.
import SwiftUI
struct RecipeDetailView: View {
var recipe:Recipe
var body: some View {
ScrollView {
VStack(alignment: .leading) {
// MARK: Recipe Image
Image(recipe.image)
.resizable()
.scaledToFill()
// MARK: Ingredients
VStack(alignment: .leading) {
Text("Ingredients")
.font(.headline)
.padding([.top, .bottom], 5)
ForEach(recipe.ingredients, id:\.self){ item in
Text("-" + item.name)
}
}
.padding(.horizontal)
// MARK: Divider
Divider()
// MARK: Directions
VStack(alignment: .leading) {
Text("Directions")
.font(.headline)
.padding([.bottom, .top], 5)
ForEach(0..<recipe.directions.count, id:\.self){ index in
Text(String(index+1) + "." + recipe.directions[index])
.padding(.bottom, 5)
}
}
.padding(.horizontal)
}
}
.navigationBarTitle(recipe.name)
}
}
struct RecipeDetailView_Previews: PreviewProvider {
static var previews: some View {
let model = RecipeModel()
RecipeDetailView(recipe: model.recipes[0])
}
}