Я хочу, чтобы quizNumber
возвращал quizNumberArray
в зависимости от того, какая ячейка выбрана.
Например, если пользователь выбрал первую ячейку, quizNumber
возвращает 1
Внутри UITableViewController
let quizNumberArray = [1,2,3,4,5,6,7,8,9,10]
var quizNum = Int()
override func tableView(_ tableView: UITableView, didSelectRowAt indexPath: IndexPath) {
let vc = storyboard?.instantiateViewController(withIdentifier: "toQuestionVC") as? QuestionVC
quizNum = quizNumberArray[indexPath.row]
}
override func prepare(for segue: UIStoryboardSegue, sender: Any?) {
if let identifier = segue.identifier {
if identifier == "toQuestionVC" {
let questionController = segue.destination as! QuestionVC
questionController.quizNumber = quizNum
}
в следующем ViewController
class QuestionVC : UIViewController {
var quizNumber = Int()
func updateQuestion(){
if quizNumber == 1 {
//.....
}
}
}
Но quizNumber
возвращает 0.