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 - Swift Tutorial
From the course: Make SwiftUI Playgrounds Applications
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
-
-
-
(Locked)
More on the view hierarchy12m 11s
-
(Locked)
Formatted numbers8m 23s
-
(Locked)
Computed properties6m 7s
-
(Locked)
Arrays9m 54s
-
(Locked)
For loops9m 42s
-
(Locked)
Use ForEach in SwiftUI8m 32s
-
(Locked)
Protocols, Hashable, and Identifiable3m 56s
-
(Locked)
Importing models and assets8m 27s
-
(Locked)
Adapting models8m 43s
-
(Locked)
Scroll view and list6m 34s
-
Work with @State and toggle buttons8m 43s
-
(Locked)
Make Button arrays7m 13s
-
(Locked)
Work with @Binding5m 59s
-
(Locked)
Enumeration types8m 45s
-
(Locked)
Selection from lists4m 21s
-
(Locked)
Optional values6m 10s
-
(Locked)
-