Hi
I update xcode to version 11.3 and my OS to Mojave (10.14.6)
I had a macos app with NSButtons binded to a NSViewController
@IBAction func Tester(_ sender: NSButton) {
Swift.print("test activé")
}
(I made it very simple to isolate my problem)
the function Tester of my viewController is never called and I can't find why
OK, the reason is in fact :
In the appDelegate, when you call the menu tester:
@IBAction func Tester(_ sender: Any) {
testerWindow().showWindow(self)
}
You create an instance of testerWindow and display a window object on screen.
But, when leaving Tester(), this instance is removed (it is not stored anywhere, it is only local to the IBAction).
However, windows stays on screen with its buttons (this is what is misleading but normal behavior), but the buttons target are now pointing to nil: they have no target to send the message for action anymore.
That is why it works by creating a global var in which to store the WindowController that is created when calling the menu, as per my previous post Dec 14, 2019 10:44 AM.