How can I implement a switch in OSX, Xcode 8, Swift 3?

I am trying to implement a switch in OSX, Xcode 8, Swift 3. I could have done this in previous iterations of Xcode using a group of switches. I believe that there should be a way to group switches in Xcode so that their selection is exclusive, but I cannot figure out how to do this. Can someone explain how to do this now?

Apple documentation explains that

NSButton configured as a switch (with the -buttonType type set to NSRadioButton) will now work in the switch group for applications associated with 10.8 and later. In order for a button to work in radio groups, they use the same action for each instance of NSButton and have the same supervisor for each button. When these conditions are met, checking one button (by changing the state-1 to 1) will remove all other buttons (by setting their -state to 0).

... but I was not able to figure out in Interface Builder how to assign the same action for each instance of NSButton. I am dragging from the second button to an action in the Xcode IDE and it seems that I cannot select the same action. Can someone explain the correct process?

Thank you very much in advance!

+4
1

, IDE - ​​, Any. , , NSButton:

demo gif

+4

Source: https://habr.com/ru/post/1666192/


All Articles