开发者

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...

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜