Here is my code:
struct ContentView : View {
let colors: [Color] = [.red, .green, .blue]
var body: some View {
VStack {
ForEach(colors.identified(by: \.self)) { color in
Text(color.description.capitalized)
.padding()
.background(color)
}
}
}
}
But I got the error:
Value of type '[Color]' has no member 'identified'
What could be the reason? I'm using Xcode 11 beta 5.
For Xcode 11 Beta 5 and above, use:
ForEach(colors, id: \.self)
For Xcode 11 Beta 4 and below use:
ForEach(colors.identified(by: \.self))
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With