问题
As I am conditionally checking, I cannot return "some view" for the func doFavoriteMath
.
private func doFavoriteMath(section: Labvalueslist) -> some View {
for numbers in userData.favoriteIDS {
if section.id == (numbers) {
return ItemRow(list: section)
}
}
}
var body: some View {
NavigationView {
List {
ForEach(userData.labvaluesUserdata) {section in
self.doFavoriteMath(section: section)
}
}
}
}
回答1:
There's no need to return an opaque type from your function. It always returns something of type ItemRow
, so the return type can be just that.
来源:https://stackoverflow.com/questions/59268923/swift-ui-missing-return-in-a-function-expected-to-return-some-view