Reputation: 57
I've been using ForEach for a while now, it has been working fine until I updated my Xcode a couple days ago, now it says "Generic parameter 'ID' could not be inferred". Anyone else experiences the same issue?
ForEach(dataArray) { data in
...
}
Upvotes: 2
Views: 1443
Reputation: 3053
Anytime you get that error, you should just use the following overload of ForEach:
ForEach(0..<dataArray.count, id: \.self) { index in
//refer to your items as dataArray[index] inside ForEach
}
You get the error because your dataArray
elements are not conforming to Identifiable
protocol.
Upvotes: 7