I started programming with Swift recently. One thing was working in the beginning but not anymore. When I control-drag a label from my Storyboard to my code to connect it (IBOutlet and IBAction in Swift) the @IBOutlet ends up in viewDidLoad() {} and I get an error.
import UIKit
class ViewController: UIViewController {
@IBOutlet weak var x1: UILabel!
@IBOutlet weak var x2: UILabel!
@IBOutlet weak var x3: UILabel!
@IBOutlet weak var x4: UILabel!
var rowLabels = [UILabel]()
override func viewDidLoad() {
super.viewDidLoad()
// should be below the other outlets instead!?!
// Error: Only instance properties can be declared @IBOutlet
@IBOutlet weak var x5: UILabel!
SetupMyThings()
}
I get rid of the error by moving the code up but how do I get it to be there in the first place?