I'm stuck at a variable declaration in Swift 3. My code looks like this:
Beginning of code
// Letter Buttons
@IBOutlet weak var LetterOneButton: UIButton!
@IBOutlet weak var LetterTwoButton: UIButton!
@IBOutlet weak var LetterThreeButton: UIButton!
@IBOutlet weak var LetterFourButton: UIButton!
@IBOutlet weak var LetterFiveButton: UIButton!
// Word Fields
@IBOutlet weak var WordLetterOne: UILabel!
@IBOutlet weak var WordLetterTwo: UILabel!
@IBOutlet weak var WordLetterThree: UILabel!
@IBOutlet weak var WordLetterFour: UILabel!
@IBOutlet weak var WordLetterFive: UILabel!
// Counter
@IBOutlet weak var CounterLabel: UILabel!
// Skip Button
@IBOutlet weak var SkipButtonLabel: UIButton!
// Define Variables
var index: Int = 0
The error appears in the following line:
var labels: [UILabel] = [WordLetterOne, WordLetterTwo, WordLetterThree, WordLetterFour, WordLetterFive]
Error message is "Cannot use instance member 'WordLetterOne' within property initializer; property initializers run before 'self' is available". Afterwards, another string is declared without any problems.
var letters: [String] = ["A", "B", "C", "D", "E"]
End of code
And help is highly appreciated!
Edit:
self.lazy var labels: [UILabel] = [WordLetterOne, WordLetterTwo, WordLetterThree, WordLetterFour, WordLetterFive]
is giving the errors "Consecutive declarations on a line must be separated by ';'" and "Instance member 'WordLetterOne' cannot be used on type 'ViewController'"