10

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

ATV
  • 4,116
  • 3
  • 23
  • 42
Cocoa Dev
  • 9,361
  • 31
  • 109
  • 177

2 Answers2

22

You can call:

Objective C:

[myPopupButton selectItemAtIndex:0]

Swift:

myPopupButton.selectItem(at: 0)

See here for details.

Guy Kahlon
  • 4,510
  • 4
  • 30
  • 41
user1118321
  • 25,567
  • 4
  • 55
  • 86
1

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

Thiem Nguyen
  • 6,345
  • 7
  • 30
  • 50
Bosko Popovic
  • 281
  • 1
  • 4
  • 4