Associate NSButton State

I am trying to associate the state of NSButton with an objectController , but I can not find in the Interface Builder "Voice Status" under Binds for the button.

Is there a way to bind this property?

+4
source share
2 answers

I assume this is an NSButton checkbox NSButton ? Bind its "value" in IB.

+6
source

If someone wants to do a two-way binding between the state of NSButton and, say, NSUserDefaultsController in Swift 2, here's how you can do it. All this gives you an answer.

 var button: NSButton! let userDefaults: NSObject = NSUserDefaultsController.sharedUserDefaultsController().values as! NSObject let options: [String:AnyObject] = [NSContinuouslyUpdatesValueBindingOption: true] button.cell!.bind("state", toObject: userDefaults, withKeyPath: "MyButtonState", options: options) userDefaults.bind("MyButtonState", toObject: button.cell!, withKeyPath: "state", options: options) 
+1
source

All Articles