2

I am new to cocoa development and I generally don't use interface builder. I have this NSPopupButton with several items. When I run the application I see the control. The first option is displayed. But I want the third option to be displayed instead. That is the default version, the only one that is selected when the control is created and displayed.

The control is not using bindings. How do I do that exclusively on Interface Builder? SO has an answer for a control using bindings, not what I want.

I have tried to add this to the runtime attributes

enter image description here

but I have this error: [ setValue:forUndefinedKey:]: this class is not key value coding-compliant for the key selectItemWithTag.

Duck
  • 34,902
  • 47
  • 248
  • 470

1 Answers1

1

You can't call objective-c methods like that with runtime attributes. Instead, typically you'd use selectedTag instead of selectItemWithTag. You are getting that error because setSelectedItemWithTag is not a property of NSPopUpButton, it is just a method, while selectedTag is a property. However, you should not set the default item like this.

The correct way to set a default displayed item is simply to make it so in interface builder. Open the menu in IB and select the item you want showing first and then click elsewhere.

Alex Zielenski
  • 3,591
  • 1
  • 26
  • 44