Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

NSPopUpButton set it to the first item

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

like image 819
Cocoa Dev Avatar asked Jan 19 '12 18:01

Cocoa Dev


2 Answers

You can call:

Objective C:

[myPopupButton selectItemAtIndex:0]

Swift:

myPopupButton.selectItem(at: 0)

See here for details.

like image 172
user1118321 Avatar answered Nov 12 '22 23:11

user1118321


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!!!

like image 1
Bosko Popovic Avatar answered Nov 12 '22 22:11

Bosko Popovic