how to randomly display data in SwiftUI?

typical use case for flash cards... I have shelves that contain boxes that contain cards. i want to randomly select a card from a box and display its data (front) and accept user input (right or wrong) and increment card.level if user selects "right" or decrement if he/she selects "wrong", after he/she has seen the back of the card. How to approach this use case? Have a nice day, and thank you!
3 Replies
aelfled
aelfled11mo ago
augment the cards with a sort field which is assigned Float.random(in:), then sort the array by that field
Timo Martinson
Timo MartinsonOP11mo ago
what range should i put in there ?
aelfled
aelfled11mo ago
0..1 should be fine
Want results from more Discord servers?
Add your server