how to generates the slots for each letter in the word
What is the exact problem ? Is it to create the display or to put letters ?
What you could do:
create a label for each letter (you have to create as many as there are letters in word).
So the best is to create an IBOutletCollection
@IBOutlet var letters: [UILabel]!
Because the number of letters may vary, you may choose to create the labels in code:
var nbLetters : Int
// You should ask player to tell how many
for i in 0..<nbLetters {
// create UILabels
let label = UILabel(frame: CGRect(x: 20 * (i + 1), y: 50, width: 20, height: 21)) // You will set the x, y position as needed
label.textAlignment = .center
label.text = "_" // When there is no text
letters.append(label)
self.view.addSubview(label)
}
You could also decide in your game that words will be 10 letters max (for instance), and then create the 10 labels in storyboard, connect to the IBOutletCollection.
Then when you select a word, you will hide the non needed labels.
When you play, you put the letter where it fits (in the correct index of letters).
For instance if T is in second (position 1 in array)
letters[1].text = "T"
Hope that will let you start.
Start coding and come back if you have other problem.
Sorry, I just notice it is SwiftUI ? What I described was for UIKit.
In SwiftUI, you should create a Stack of Text for the letters.