Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

NSButton with two or more actions

I am iOS developer and I want to develop a Mac app (it's basically a "port" from an iOS app). In IB in iOS is very easy to connect one UIButton to two or more actions. I have noticed that in a Mac App I only can connect a NSButton to a single action. Is there a way to connect an NSButton to more than one action?

like image 766
Teofilo Israel Vizcaino Rodrig Avatar asked Oct 05 '22 00:10

Teofilo Israel Vizcaino Rodrig


1 Answers

Is there a way to connect an NSButton to more than one action?

NO. This is not supported in OSX Cocoa applications.

You need to setAction: yourself based on conditions, But only one at a time can be used.

In case 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];
}
like image 182
Anoop Vaidya Avatar answered Oct 25 '22 16:10

Anoop Vaidya