Я пишу базовое c приложение для викторин в XCode, используя одну страницу, и мне нужна помощь о том, как я могу проверить ответы. У меня есть ряд вопросов и ответов, которые совпадают. Когда пользователь вводит свой ответ в текстовое поле, как я могу проверить его правильность?
@IBOutlet var questionLabel:UILabel!
@IBOutlet var answerField:UITextField!
@IBOutlet var instructionsLabel:UILabel!
let questions:[String] = ["In what country is the Christ the Redeemer statue located in?", "In what country is Machu Picchu lacated in?", "In what country is the Taj Mahal located in?", "In what country is the Great Pyramids of Giza located in?","In what country is Petra located in?","In what country is the Great Wall located in?", "In what country is the ruins if Chichen Itza located in?"]
let answers:[String] = ["Brazil", "Peru", "India", "Egypt", "Jordan", "China", "Mexico"]
var currentQuestionIndex:Int = 0
override func viewDidLoad() {
super.viewDidLoad()
// Do any additional setup after loading the view.
currentQuestionIndex = questions.count - 1
}
@IBAction func showNextQuestion(sender:AnyObject){
if(currentQuestionIndex<questions.count-1) {
currentQuestionIndex = currentQuestionIndex + 1
} else {
currentQuestionIndex = 0
}
questionLabel.text = questions[currentQuestionIndex]
}
@IBAction func checkAnswer(){
}
}