Your Second iOS & SwiftUI App

Nov 4 2021 · Swift 5.5, iOS 15, Xcode 13

Part 3: Managing Rows

21. ForEach

Episode complete

Play next episode

Next
About this episode

Leave a rating/review

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

Get immediate access to this and 4,000+ other videos and books.

Take your career further with a Kodeco Personal Plan. With unlimited access to over 40+ books and 4,000+ professional videos in a single subscription, it's simply the best investment you can make in your development career.

Learn more Already a subscriber? Sign in.

Heads up... You’re accessing parts of this content for free, with some sections shown as obfuscated text.

Heads up... You’re accessing parts of this content for free, with some sections shown as obfuscated text.

Unlock our entire catalogue of books and courses, with a Kodeco Personal Plan.

Unlock now

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)