NSPopUpButton set it to the first item

I have a clear button in an application for Mac OS.
When the button is pressed, it clears all the values ​​of the form and resets NSPopUpButtonto the first element.

The question is how to change the control NSPopUpButtonwith code.

thank

+5
source share
2 answers

You may call:

Goal C:

[myPopupButton selectItemAtIndex:0]

Swift:

myPopupButton.selectItem(at: 0)

See here for more details .

+14
source

When the argument is 0, it means nil , and it works. If you put another number (e.g. 2), this will not work, because the argument is not a number !!!

+1
source

All Articles