Hello. Can anyone explain to me that in which case we declare the “id: .self” in ForEach/List Command? from module 1 and module 2 (Foundation), I see Chris declare in two way but I don’t know why
for Example:
ContentView1:
struct Detail: View {
var newUI:card
var body: some View {
ScrollView{
Text(newUI.name)
ForEach(newUI.quotes, id: .self) { t in
-
Text(t)* } }
}
}
ContentView2:
struct ContentView: View {
@ObservedObject var model = cardView()
var body: some View {
ScrollView{
*ForEach (model.cardArray){ t in*
-
*
-
}Image(t.image)* }
Thank you so much