0

I've been learning Xcode for about 8 months and I need help with step by step instructions.

I've been trying to program these buttons with various internet resources and I'm having difficulty. How can I program this button to uncheck these boxes when checked?

Checkboxes with a Button

I attempted to use the following resources:

1.Select/deselect buttons swift xcode 7

2.Disable a Button

3.https://developer.apple.com/documentation/appkit/nsbutton/1528907-state?language=objc

4.https://developer.apple.com/library/archive/documentation/Cocoa/Conceptual/Button/Concepts/CheckBoxes.html


@IBOutlet weak var optionOne: NSButton!
@IBOutlet weak var optionTwo: NSButton!
@IBOutlet weak var optionThree: NSButton!

@IBAction func buttonClick(_ sender: NSButton) {
    var optionOne:  Type  {NSButton.StateValue.off}
    var optionTwo:  Type  {NSButton.StateValue.off}
    var optionThree:  Type  {NSButton.StateValue.off}
}

1 Answers1

0

I woke up this morning and within 10 minutes this came to me. And it functions as long as it's referenced.


@IBOutlet weak var optionOne: NSButton!
@IBOutlet weak var optionTwo: NSButton!
@IBOutlet weak var optionThree: NSButton!

@IBAction func resetButton(_ sender: Any) {
    if optionOne.state.rawValue == 1 {optionOne.state = NSControl.StateValue(rawValue: 0)}
    if optionTwo.state.rawValue == 1 {optionTwo.state = NSControl.StateValue(rawValue: 0)}
    if optionThree.state.rawValue == 1 {optionThree.state = NSControl.StateValue(rawValue: 0)}

}