I couldn't find anything really, but try this.
// Add new function in PostView
struct PostView {
...
func tweetCell(data: datatype) -> some View {
VStack {
if i.groupsShortcut == self.shortcut {
tweetCellTop ...
if pic != "" {
tweetCellMiddle ...
}
tweetCellBottom ...
}
}
}
}
Then in the ForEach
, do
ForEach(observedData.datas, content: self.tweetCell(data:))
This is what I meant when I said to separate them into multiple pieces. So the compiler can figure them out separately. And we'll also get a more pinpoint location of the error.
What am I messing?
tweetCell
is inside PostView
And also the VStack
encompassing the entire function
what about
Use of unresolved identifier 'i'
Oh right, you use i
, I used data
You can do
func tweetCell(data i: datatype) -> some View {
PS
I really wouldn’t advice that you tried SwiftUI as your first project (not one with so much complexity), compilers aren’t exactly helpful as of yet, and could hinder the learning.
There’s an -> some View
at the end of tweetCell
Also there’s a VStack
(with the {}
bracket) covering the entire block in tweetCell
.
your are awesome, that solved my problem. Thaaaanks
I've had the same problem half an hour ago. After all it appeared that a misspelled variable name inside the ForEach (actually in the if statement) causes this "Unable to infer complex closure return type; add explicit type to disambiguate"