NSPopUpButton set it to the first item

6.6k views Asked by At

I have a clear button in my Mac OS app.
When the button is pressed, it clears all the values of the form and resets the NSPopUpButton to the first item.

The question is how do I change the NSPopUpButton control with code.

Thanks

2

There are 2 answers

0
user1118321 On BEST ANSWER

You can call:

Objective C:

[myPopupButton selectItemAtIndex:0]

Swift:

myPopupButton.selectItem(at: 0)

See here for details.

1
Bosko Popovic On

When argument is 0 it means nil, and that works. If you put other number (for example 2 ) this will not work because the argument is not number!!!