I have a UILabel called nihoshim and the element in the last index is a number I want to increase. alpha is a collection of UIButton.
@IBAction func wordChoser(_ sender: UIButton) {
let tag = sender.tag - 1
var liel = nihoshim.text!
let index = Int(liel.endIndex) // error here
var alephbet = ["א","ב","ג","ד","ה","ו","ז","ח","ט","י","כ","ל","מ","נ","ס","ע","פ","צ","ק","ר","ש","ת"]
if gameLabel.text!.count <= 3 {
gameLabel.text = gameLabel.text! + alephbet[alpha.index(after: tag) - 1]
sender.isHidden = true
} else if gameLabel.text!.count <= 3 {
gameLabel.text = gameLabel.text! + alephbet[alpha.index(after: tag) - 1]
sender.isHidden = true
}
}
The error is:
Initializer 'init(_:)' requires that 'String.Index' conform to 'BinaryInteger'
alephbet[alpha.index(after: tag) - 1]should be the same asalephbet[tag].