Array of NSButton
-
26-09-2019 - |
Question
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.
Solution
IB doesn't handle arrays. You can add them using a loop in your code instead.
OTHER TIPS
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...
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow