Jamison Dance
Jamison Dance

Reputation: 20184

How do I populate an NSPopupButton with an array of strings?

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?

Upvotes: 1

Views: 1580

Answers (1)

smorgan
smorgan

Reputation: 21579

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.

Upvotes: 2

Related Questions