I need a loop in the SwiftUI and the number of loop is based on a condition so I don't think I can use the forEach loop. I wonder if it's possible to use a while loop in SwiftUI or is there an equivalent?
Can I use while loop in SwiftUI
No, it is not possible, and no, there is no equivalent.I wonder if it's possible to use a while loop in SwiftUI or is there an equivalent?
If your view contains dynamic number of contents, you may need to construct a collection (using while maybe) in some appropriate action (onAppear for example), and use ForEach with the collection.the number of loop is based on a condition