views:

123

answers:

3

I wonder if I can do something like

IBOutlet NSButton * aButton[100];

It turns out that aButton cannot be seen in the interface builder.

My app has lots of buttons and I want to see if there are way I can use looping to iterate the state of all buttons.

+2  A: 

No, you can't use an array as an outlet. Some options:

  • create a NSButton subclass that does what you want to do
  • walk the view hierarchy at runtime to find the buttons

OTOH, if your UI has 100 buttons, you've probably got bigger problems...

Nicholas Riley
+2  A: 

IB doesn't handle arrays. You can add them using a loop in your code instead.

progrmr
+2  A: 

You may find an NSMatrix of NSButtonCells easier to work with, and unlike a C array of NSButtons, you can create one in IB.

Peter Hosey