-3

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?

Anju
  • 563
  • 2
  • 6
  • 13

1 Answers1

2

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

Oscar Apeland
  • 6,422
  • 7
  • 44
  • 92