Btw, does the error occur when you added if statement, or only that it appears at if statement? Because the current compiler can have misleading error location for SwiftUI. If it happens right after you added if, it’d be more definite.
Anyhow, as the error said, the compiler couldn’t guess the type of everything you typed in the allotted time. The way SwiftUI works, it needs to guess everything in body function in one go.
So if it is really because the whole function is too long, you can break it into multiple functions/compute properties.
But I’m suspecting that there is a wrong type than the one you intended in there simply because I’ve done longer functions and it works fine.
Ok, I think I found it, if you use exact same code as the first post (aka, copy-and-paste), it leads to incorrect operators
if i.groupsShortcut == self.shortcut && i.pic!=""{
turns into
if (i.groupsShortcut == self.shortcut) && ((i.pic!)=""){
but you want
if (i.groupsShortcut == self.shortcut) && (i.pic != "") {
Which can be fixed by proper spacing
if i.groupsShortcut == self.shortcut && i.pic != "" {
Note the space between i.pic and "". Swift operator is somewhat sensitive to whitespace before and after it. That's the only place you need to be wary of space really.
that's what it's doing, Once you're inside the first bracket, you already know the shortcuts are the same. Once's you're inside the second bracket, you also know that i.pic != "". Or maybe I'm missing something.
no in case of if i.groupsShortcut == self.shortcut && i.pic != "" { its be true if both are true. therefore I want to check first the shortcuts and then the pic