NSButton with two or more actions

I am an iOS developer and I want to develop an application for Mac (this is basically a β€œport” from an iOS application). In IB on iOS, it is very easy to connect one UIButton to two or more actions. I noticed that on the Mac App, I can connect NSButton to one action. Is there a way to connect NSButton to multiple actions?

+4
source share
1 answer

Is there a way to connect NSButton to multiple actions?

NO . This is not supported on Cocoa OSX applications.

You need setAction: yourself based on conditions, but you can only use one at a time.

If you want to call two methods (actions), in the IBAction method you need to call them.

 -(IBAction)multipleActions:(id)sender{ [self method1:sender]; [self method2:sender]; } 
+4
source

Source: https://habr.com/ru/post/1483274/


All Articles