Im new to stack overflow so sorry if I seem a bit noobish. I am currently trying to make an app for IOS but I cant get some simple code down. Basically I need to randomly select 5 elements from an array list without repeating an element. I have a rough draft, but it only displays one element...Please help.
Here is my current Swift 3 code.
let array1 = ["salmon", "turkey", "salad", "curry", "sushi", "pizza"]
let randomIndex1 = Int(arc4random_uniform(UInt32(array1.count)))
print(array1[randomIndex1])
Aucun commentaire:
Enregistrer un commentaire