ForEach
extension ForEach where Content: View
-
Creates an instance that creates views for each object in a collection of
ObjectSnapshot
s. The objects’NSManagedObjectID
are used as the identifierlet 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 theForEach
instance uses to create views dynamicallycontent
The view builder that receives an
ObjectPublisher
instance and creates views dynamically. -
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 theForEach
instance uses to create views dynamicallycontent
The view builder that receives an
ObjectPublisher
instance and creates views dynamically. -
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 theForEach
instance uses to create views dynamicallycontent
The view builder that receives an
ObjectPublisher
instance and creates views dynamically. -
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 theForEach
instance uses to create views dynamicallycontent
The view builder that receives a
ListSnapshot.SectionInfo
instance and creates views dynamically. -
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 theForEach
instance uses to create views dynamicallycontent
The view builder that receives an
ObjectPublisher
instance and creates views dynamically.