From the course: Complete Guide to SwiftUI
Unlock this course with a free trial
Join today to access over 24,600 courses taught by industry experts.
Iteration with ForEach
From the course: Complete Guide to SwiftUI
Iteration with ForEach
- [Instructor] I'm building out my wire frame for my app nicely. However, the order items on top and the menu below have more than one item. You'll need some iteration over a list of these. There's several options in SwiftUI. The simplest is the for each, which works similar to a Swift four loop. So we're going to go to where we have the H stack here. Now this is much easier when you start dealing with H stacks and stuff to actually have a code folding ribbon over here in your code. So I'm going to go over here to X code preferences, and go over here to editing, and turn on the code folding ribbon, which you'll find makes life a lot easier in SwiftUI. And then you can see that we've got the code folding ribbon, which will give us where our stacks are here. And I'm going to go to this H stack for the bottom one here, line 41. And I'm going to code fold it. And the reason I do that is 'cause now I can put code around it real easy, and I can see what I'm doing. So I'm going to put in a…
Contents
-
-
-
-
(Locked)
Embed a stack view6m 29s
-
(Locked)
Text views3m 41s
-
(Locked)
Image views with SF Symbols5m 22s
-
(Locked)
Iteration with ForEach5m 13s
-
(Locked)
Images and assets4m 56s
-
(Locked)
Labels2m 22s
-
Add view2m 49s
-
(Locked)
Challenge: Add views26s
-
(Locked)
Solution: Add views2m 33s
-
(Locked)
Extract subviews8m 4s
-
(Locked)
Subviews with parameters6m 37s
-
(Locked)
Challenge: Ratings view44s
-
(Locked)
Solution: Ratings view3m 55s
-
(Locked)
-
-
-
-
-
-
-
-
-
-
-
-
-
-