From the course: Make SwiftUI Playgrounds Applications

Unlock this course with a free trial

Join today to access over 24,700 courses taught by industry experts.

Use ForEach in SwiftUI

Use ForEach in SwiftUI

- You've gotten the idea of for loops, which we use in Swift for manipulating arrays. Swift UI has a similar way of displaying views based on arrays, but not quite. So we're going to look now at the for each loop and see the similarities and differences. So let's go back to the Huli Pizza takeout app. So I'm going to close that up and go over here to Huli Pizza takeout. And I'm going to go make a new view this time. So we're going to play with something new. So I'm going to go over here, hit the add Swift file button, make a new file, and it's going to be called ratings view. Okay and then in my code, you can put in view and you can hit return there, and that'll make a struct and we can call that ratings view. There, okay, so now we've got our ratings view and I'm going to get rid of hello world here 'cause I'm going to start working on my code right there. And delete that. Put it in H stack. Okay. All right, now we…

Contents