Array of NSButton
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 lo开发者_StackOverflow中文版oping to iterate the state of all buttons.
IB doesn't handle arrays. You can add them using a loop in your code instead.
You may find an NSMatrix of NSButtonCells easier to work with, and unlike a C array of NSButtons, you can create one in IB.
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...
精彩评论