Can I use while loop in SwiftUI

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?

I wonder if it's possible to use a while loop in SwiftUI or is there an equivalent?

No, it is not possible, and no, there is no equivalent.

the number of loop is based on a condition

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.


Can I use while loop in SwiftUI
 
 
Q