Я строю эту программу для использования во время Trivial Pursuit для вопросов. У меня возникли проблемы с получением размера словаря для хранения в переменной size
функции. Я пробовал каждый способ сохранить переменную, но всегда получаю нулевое значение.Выход из закрытия Swift
var size:Int = Int()
@IBOutlet var questionLabel: UILabel!
@IBOutlet var answerLabel: UILabel!
@IBAction func answerButton(sender: AnyObject) {
}
func getSize() {
self.size = scienceDictionary.count
}
var scienceDictionary = ["What is the chemical process that converts sugar into alcohol?": "Fermentation",
"Where in your body would you find you hippocampus?": "Brain",]
override func viewDidLoad() {
super.viewDidLoad()
print(size)
}
override func didReceiveMemoryWarning() {
super.didReceiveMemoryWarning()
// Dispose of any resources that can be recreated.
}
Это будет работать, но я пытаюсь рандомизировать его со случайным числом, но я не могу сохранить размер словаря или переменную randomNumber в ViewController. – user3103854