1

In my application, I save user preferences and one of the preferences is whether to show any NSMenuItems as buttons in the home window. I don't have problems to create the buttons dynamically, but I can't pass the action of the NSMenuItem to the NSButton. I have already tried:

[newButton setAction:[theItem action]];

UPDATE

I just have to set the target as self

[newButton setTargert:self];

And move the code to the class that send the action to the NSMenuItem

Javier Beltrán
  • 756
  • 5
  • 26

2 Answers2

2

Check the following:

  1. message selector ([theItem action]) is not NULL.
  2. target for the newButton is set.
shim
  • 9,289
  • 12
  • 69
  • 108
Swetha
  • 115
  • 1
  • 7
  • I checked, now i know the problem is that, the button don't recognize the item action. I guess it is because the action of the item is in another object. – Javier Beltrán Sep 08 '11 at 14:14
1

You will need to set the UIButton instance's target and action properties. This question shows how.

Community
  • 1
  • 1
Beltalowda
  • 4,558
  • 2
  • 25
  • 33