mercredi 30 août 2017

Swift: how to call the function which calls a random function?

I have four functions which I want to activate randomly. This is the code I have so far, which I get no errors from. However, I get an error "Expression Resolves to an unused function" when I try to call the createSquare() function.

func createSquare () -> () -> () {
    let squares = [self.squareOne, self.squareTwo, self.squareThree, self.squareFour]

    let randomSquare = Int(arc4random_uniform(UInt32(squares.count)))

    return squares[randomSquare]

}
if gameIsOn == true {
    createSquare()
}

How can I successfully call the function createSquare()?




Aucun commentaire:

Enregistrer un commentaire