I have a simple example. I connected the left button1 and label1 with ctrl-draging it to the contollerclass.
How can I do the same for the right button2 label2 programaticly (without ctrl-draging)
That´s my code:
class ViewController: NSViewController {
@IBOutlet weak var label1: NSTextField! //connected with ctrl-drag
@IBOutlet weak var button1: NSButton! //connected with ctrl-drag
@IBOutlet weak var label2: NSTextField! //not yet connected
@IBOutlet weak var button2: NSButton! //not yet connected
@IBAction func button1Pressed(_ sender: Any) //connected with ctrl-drag
{ label1.stringValue = "button-I"
button1.title = "pressed"
}
@IBAction func button2Pressed(_ sender: Any) //not yet connected
{ label2.stringValue = "button-II"
button2.title = "pressed"
}
override func viewDidLoad() {
super.viewDidLoad()
}
}