Your Second iOS & SwiftUI App

Nov 4 2021 Swift 5.5, iOS 15, Xcode 13

Part 3: Managing Rows

21. ForEach

Lesson Complete

Play Next Lesson
Next
Save for later
About this episode
See versions

See course reviews

See forum comments
Cinema mode Mark as Complete Download course materials
Previous episode: 20. Introduction Next episode: 22. Challenge: New Book Sheet

This video was last updated on Nov 4 2021

Heads up... You've reached locked video content where the transcript will be shown as obfuscated text.

You can unlock the rest of this video course, and our entire catalogue of books and videos, with a kodeco.com Professional subscription.

Take a look at these two initializers. One is for a List view, and the other one, a ForEach view.

List(library.sortedBooks) { book in
ForEach(library.sortedBooks)
    NavigationView {
      List(/*@START_MENU_TOKEN@*/0 ..< 5/*@END_MENU_TOKEN@*/) { item in
        ForEach(library.sortedBooks) { book in
    NavigationView {
      List {
        ForEach(library.sortedBooks) { book in
      }
      .navigationBarTitle("My Library")
    }
  }
}
      List {
        Button {

        } label: {
          Text("Add New Book")
        }

        ForEach(library.sortedBooks) { book in
        Text("Add New Book")
          .font(.title2)
        }
        VStack {
          Text("Add New Book")
            .font(.title2)
        }

        ForEach(library.sortedBooks) { book in
        VStack {
          Image(systemName: "book.circle")
          Text("Add New Book")
          Image(systemName: "book.circle")
            .font(.system(size: 60))
          Text("Add New Book")
VStack(spacing: 6) {
        } label: {
          Spacer()

          VStack(spacing: 6) {
            Image(systemName: "book.circle")
              .font(.system(size: 60))
            Text("Add New Book")
              .font(.title2)
          }
          
          Spacer()
        }
        }
        .buttonStyle(.borderless)
        .padding(.vertical, 8)