Random word(Meaningful) generation

411 Views Asked by At

I am trying to build a game in SpriteKit. which I planned to create some random words. I found some links but unfortunately, I am not able to figure out a solution. Does anybody know of a way to generate a random word?

1

There are 1 best solutions below

1
Oscar Apeland On

The easiest way would probably be to just make an Array of accepted random words and pick a random element.

let words = ["One", "Fish", "Two", "Fishes", "Red", "Blue"]

Swift 4.2: let word = words.randomElement()

Pre-Swift 4.2 Look at this question