I have an NSView extension with a simple function called clearControllersInView (), which takes all the controllers in the view and sets them to the default value (i.e. check boxes for pop-ups, pop-ups and combos for the first menu item, text fields for empty lines ) I had no problems with this in Swift 3.
I use the current beta version of Xcode 9 and upgrade this extension to Swift 4. The problem is in the section processing flags, where I get the error "NSOffState" is not available in Swift "when trying to install checkbox for NSOffState:
if item is NSButton {
let checkbox = item as? NSButton
checkbox?.state = **NSOffState** -- *'NSOffState' is unavailable in Swift*
}
I got the same error elsewhere in this program where I check the value of a checkbox. I was able to temporarily fix these instances by checking the raw control value: if checkbox.state == NSOnState - error
if checkbox.state.rawValue == 1 - no error
Could not find a solution by doing a search here or Google in general. Any help would be greatly appreciated!
source
share