나는 사소한 추구 중에 질문을하기 위해이 프로그램을 작성하고 있습니다. 함수에서 변수 size
에 저장 될 사전의 크기를 가져 오는 데 문제가 있습니다. 변수를 저장할 수있는 모든 방법을 시도했지만 항상 0의 값을 얻습니다. 기본적으로폐점 시간 빠름
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.
}
그게 작동하지만 난 임의의 숫자로 무작위로 노력하고있어하지만 ViewController에 사전 또는 randomNumber 변수의 크기를 저장할 수 없습니다. – user3103854