Search code examples
cocoansbutton

calling action obtained from button


I have following requirements:

  1. Obtain action associated with NSButton using : - (SEL)action
  2. Call the obtained action.

Can we perform 2nd pt. Generally we invoke an action like this- [self abc:nil] just thinking if we can invoke the method obtained from 2nd pt. in same way!


Solution

  • Try:

    SEL actionSelector = [button action];
    [self performSelector: actionSelector withObject:nil];