This maybe a stupid question, but I want to know if I can copy the “event handler” of a control on objective C or not. e.g I have a button “FIRST”, this button will fire the method “clickEventHandler” whenever user click it. Now I have a button “SECOND”, I just need second button does similar what the first button does no matter what first button does.
Please give me a solution for this. Any recommend are welcome also.
Given the target and action for buttons is generally set using Interface Builder, I think the best solution might be to have a common method which “routes” the event. So have both buttons call:
You can then change the routing at runtime without the need to edit the buttons in IB.
EDIT (after question from OP):
In order to get the action (and target) from the button programmatically, just access the
actionandtargetproperties of theNSButtonCell.