Hi
When wiring things in a Storboard and control+draging to let a button show a window in a macOS application where this code
will be added ? in which file ? can it be editied by code ?
--
Kindest Regards
where does the code for first option goes ? is it in a file that we can see its source code ?
First option, you mean control-drag from the button ?
No, it is not in a separate file, it is directly in the button attributes, done automatically by compiler.
You can do the test:
- define a segue from the button
- define an IBOutlet for the button : goToSecondViewButton
In viewDidload, add:
print(goToSecondViewButton.action)
You will get:
Optional(perform:)
The action associated with the segue is perform() built in function.
If you want now to override this segue:
add in viewDidLoad:
goToSecondViewButton.action = #selector(newAction(sender:))
goToSecondViewButton.target = self // Needed, otherwise, crash
and define a func for this selector in the ViewController class:
@objc func newAction(sender: NSButton) {
print("Overriden")
}
Now, when you click the button, you do not segue anymore but get on console:
Overriden