I am trying to make an app for my friends and I to randomly decide our draft order for fantasy sports. Right now with my app, when the button is clicked, a random name from the array is selected and displayed on the screen. However, when a name shows up, I would like to have it removed so that it can't appear again. The removeName
function has been my latest attempt to try this, but it gives me an error. Does anyone know how to do this? Here is the code I am currently using.
let adam = "Adam"
let connor = "Connor"
let drew = "Drew"
let schwenk = "Schwenk"
let langan = "Langan"
let tram = "Tram"
let trey = "Trey"
let joey = "Joey"
let nate = "Nate"
let goose = "Goose"
var names = [adam, connor, drew, schwenk, langan, tram, trey, joey, nate, goose]
func pickName() -> String {
let randomName = Int(arc4random_uniform(UInt32(names.count)))
return names[randomName]
}
func removeName() {
let randomName = Int(arc4random_uniform(UInt32(names.count)))
let namesIndex = randomName
names.remove(at: namesIndex)
}