# ForEach

    extension ForEach where Content: View

### Public

- `init(_:content:)`

  Creates an instance that creates views for each object in a collection of `ObjectSnapshot`s. The objects’ `NSManagedObjectID` are used as the identifier

      let people: [ObjectSnapshot<Person>]

      var body: some View {

         List {

             ForEach(self.people) { person in

                 ProfileView(person)
             }
         }
         .animation(.default)
      }

  #### Declaration

  Swift

      public init<O: DynamicObject>(
          _ objectSnapshots: Data,
          @ViewBuilder content: @escaping (ObjectSnapshot<O>) -> Content
      ) where Data.Element == ObjectSnapshot<O>, ID == O.ObjectID

  #### Parameters

  `objectSnapshots` | The collection of `ObjectSnapshot`s that the `ForEach` instance uses to create views dynamically
  `content` | The view builder that receives an `ObjectPublisher` instance and creates views dynamically.

- `init(objectIn:content:)`

  Creates an instance that creates views for each object in a `ListSnapshot`.

      @ListState
      var people: ListSnapshot<Person>

      var body: some View {

         List {

              ForEach(objectIn: self.people) { person in

                  ProfileView(person)
              }
         }
         .animation(.default)
      }

  #### Declaration

  Swift

      public init<O: DynamicObject>(
          objectIn listSnapshot: Data,
          @ViewBuilder content: @escaping (ObjectPublisher<O>) -> Content
      ) where Data == ListSnapshot<O>, ID == O.ObjectID

  #### Parameters

  `listSnapshot` | The `ListSnapshot` that the `ForEach` instance uses to create views dynamically
  `content` | The view builder that receives an `ObjectPublisher` instance and creates views dynamically.

- `init(objectIn:content:)`

  Creates an instance that creates views for each object in a collection of `ObjectPublisher`s.

      let people: [ObjectPublisher<Person>]

      var body: some View {

         List {

             ForEach(objectIn: self.people) { person in

                 ProfileView(person)
             }
         }
         .animation(.default)
      }

  #### Declaration

  Swift

      public init<O: DynamicObject>(
          objectIn objectPublishers: Data,
          @ViewBuilder content: @escaping (ObjectPublisher<O>) -> Content
      ) where Data.Element == ObjectPublisher<O>, ID == O.ObjectID

  #### Parameters

  `objectPublishers` | The collection of `ObjectPublisher`s that the `ForEach` instance uses to create views dynamically
  `content` | The view builder that receives an `ObjectPublisher` instance and creates views dynamically.

- `init(sectionIn:content:)`

  Creates an instance that creates views for `ListSnapshot` sections.

      @ListState
      var people: ListSnapshot<Person>

      var body: some View {

         List {

             ForEach(sectionIn: self.people) { section in

                 Section(header: Text(section.sectionID)) {

                     ForEach(objectIn: section) { person in

                         ProfileView(person)
                     }
                 }
             }
         }
         .animation(.default)
      }

  #### Declaration

  Swift

      public init<O: DynamicObject>(
          sectionIn listSnapshot: ListSnapshot<O>,
          @ViewBuilder content: @escaping (ListSnapshot<O>.SectionInfo) -> Content
      ) where Data == [ListSnapshot<O>.SectionInfo], ID == ListSnapshot<O>.SectionID

  #### Parameters

  `listSnapshot` | The `ListSnapshot` that the `ForEach` instance uses to create views dynamically
  `content` | The view builder that receives a `ListSnapshot.SectionInfo` instance and creates views dynamically.

- `init(objectIn:content:)`

  Creates an instance that creates views for each object in a `ListSnapshot.SectionInfo`.

      @ListState
      var people: ListSnapshot<Person>

      var body: some View {

         List {

             ForEach(sectionIn: self.people) { section in

                 Section(header: Text(section.sectionID)) {

                     ForEach(objectIn: section) { person in

                         ProfileView(person)
                     }
                 }
             }
         }
         .animation(.default)
      }

  #### Declaration

  Swift

      public init<O: DynamicObject>(
          objectIn sectionInfo: Data,
          @ViewBuilder content: @escaping (ObjectPublisher<O>) -> Content
      ) where Data == ListSnapshot<O>.SectionInfo, ID == O.ObjectID

  #### Parameters

  `sectionInfo` | The `ListSnapshot.SectionInfo` that the `ForEach` instance uses to create views dynamically
  `content` | The view builder that receives an `ObjectPublisher` instance and creates views dynamically.