I have four buttons with tag "1", "2", "3" and "4" . I want to change the title of all buttons when i will click any one of the button. my code is -
@IBAction func answerButtonAction(_ sender: UIButton) {
if answerButton.tag == 1 {
answerButton.setTitle(questionBank.list[questionNumber].answer1,
for: .normal)
} else if answerButton.tag == 2 {
answerButton.setTitle(questionBank.list[questionNumber].answer2,
for: .normal)
} else if answerButton.tag == 3 {
answerButton.setTitle(questionBank.list[questionNumber].answer3,
for: .normal)
} else {
answerButton.setTitle(questionBank.list[questionNumber].answer4,
for: .normal)
}
}
But my code is not working