Following part 3 of Apple's tutorial on SwiftUI, Handling User Input, I get this error:
Unable to infer complex closure return type; add explicit type to disambiguate
I'm using the same code as the tutorial (even coping from the 'Complete' sample code doesn't resolve the error).
Does anyone have a cue what is going wrong here?
struct LandmarkRow: View {
var landmark: Landmark
var body: some View {
HStack {
landmark.image(forSize: 50)
Text(verbatim: landmark.name)
Spacer()
if landmark.isFavorite {
Image(systemName: "star.fill")
.imageScale(.medium)
}
}
}
}
Regardless of the cause of the issue, how could you indeed add an explicit type to disambiguate here? What would the return type in such a case be?
--
Update
Apparently you should not continue with your result of the 2nd tutorial with the 3rd. Some things changed in between of the tutorials that is not documented in the tutorial. I've added the project files to Github so you can check out the diff.
It's better to start the 3rd tutorial fresh with a fresh download of the Project files of the 3rd tutorial.
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…