I am working with on multiple choose answer quiz app.
var itemsTemp = ["ant","bat", "bear", "bee", "bird", "butterfly", "camel", "cat", "cheetah","chick", "chicken"]
Updated Here is example of my quiz app.
let answerIndex = Int.random(in: 0...3) // for correct answer
itemsTemp!.shuffle() // to multiple choose option change.
here is the error:
Thread 1: Fatal error: each layout item may only occur once
Bellow code crashing
LazyVGrid(columns: [GridItem(),GridItem()],spacing: 16) {
ForEach(itemsTemp) { item in
VStack {
Text(item).id(UUID())
.matchedGeometryEffect(id:UUID(), in: namespace, isSource: !show)
.onTapGesture{
print(" tapped!")
}
}.matchedGeometryEffect(id: "container\(UUID())", in: namespace)
}
}
it's a quiz app so multiple choose option to select correct answer. array item will be occur in for each loop multiple time.
So need to each layout item multiple occur.