How to connect a button to a method in Mac OS X

I'm used to programming for the iPhone. There I would be hooked up to the action button and then the method of creating the following method: -(IBAction) DoStuff{…}. Then I would exit for the button, and then the actual button in Interface Builder. Then I connect the button to the outlet, and then connect the button to the action by clicking on the circle next to Touch Up Inside and drag it to File Owner and select my action.

I am new to Mac programming, so I tried to drag it from the executable to the file I wanted, but this did not allow me to establish a connection. Should I do this programmatically or what? How to make this button trigger an action in my code?

+5
source share
3 answers

The main difference is that iOS controls can have several actions for different events, but there is only one main action for managing Mac OS X (in some cases there are others that can be configured programmatically).

When you right-click on a button in Mac nib, it’s performClick:located in the “Received Actions” section; this is not an event. The only entry in the Sent Actions section is the selector, which is the only thing you can connect to an action on another object.

" ", / , , .

+4

, UIKit :

- (IBAction)actionName:(id)sender;

. / .

+3

Control-Click , , . .

+1

All Articles