Answers for "i don't have ID in my model in SwiftUI how to get it to ForEach loop"

1

foreach swiftui object

struct ContentView: View {
    let colors: [Color] = [.red, .green, .blue]

    var body: some View {
        VStack {
            ForEach(colors, id: \.self) { color in
                Text(color.description.capitalized)
                    .padding()
                    .background(color)
            }
        }
    }
}
Posted by: Guest on January-07-2020

Code answers related to "i don't have ID in my model in SwiftUI how to get it to ForEach loop"

Code answers related to "Swift"

Browse Popular Code Answers by Language