views:

298

answers:

1

Simple question, but I am struggling a little to understand how Interface Builder interacts with the rest of the program developed in X-Code.

My UI has an NSPopupButton that I would like to fill with an array of strings that I provide. I have a controller class that defines the method to execute when the button is clicked. Is that where I would populate the NSPopupButton? It seems like I would need to initialize is somewhere, but I am confused about exactly where to do it. I know I need to use addItemsWithTitles, but where do I call that?

+2  A: 

Assuming the list isn't changing over time, awakeFromNib (in the controller) would be a good place to populate the menu. If it's dynamic, then you'd want to populate it when the source of those strings changes.

smorgan
How do I refer to the popup button in awakeFromNib? Or do I just connect it to awakeFromNib in IB?
Jergason
You need to make an outlet for the button in your controller, and wire it up in IB.
smorgan