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)
source share