April 2020
Intermediate to advanced
528 pages
15h 40m
English
View objects make up the UI, so developers typically create, configure, and connect view objects using Interface Builder. The parts of the model layer, on the other hand, are typically set up in code.
In the project navigator, select ViewController.swift. Add the following code that declares two arrays of strings and an integer.
class ViewController: UIViewController {
@IBOutlet var questionLabel: UILabel!
@IBOutlet var answerLabel: UILabel!
let questions: [String] = [
"What is 7+7?",
"What is the capital of Vermont?",
"What is cognac made from?"
]
let answers: [String] = [
"14",
"Montpelier",
"Grapes"
]
var currentQuestionIndex: Int = 0
...
}
The arrays are ordered lists containing questions and answers. ...
Read now
Unlock full access