I wanted to use an NSButton's integerValue to pass on information in a method and ran into a curious bug: whatever I set a value to - whether integerValue, stringValue, or floatValue, when I read it out, it's 1.
NSButton inherits from NSControl and should have the usual set of values... but all of them, including strings, resolve to 1.
Nothing I can see in NSControl.h or NSButton.h points to xxValue being anything other than ordinary properties.
I'm working in Xcode 9/Swift 4/macOS 10.12.6 - is this a known problem? Is this documented anywhere? I've used .tag as a workaround but would prefer not to.
It’s not a bug.
From the documentation of NSButton
:
For most types of buttons, the value of the button matches its state—the value is 1 for on, 0 for off, or -1 for mixed. For pressure-sensitive buttons, the value of the button indicates pressure level instead.