Jef
Jef

Reputation: 1

NSUserDefaults & bindings

How can I synchronize two interface elements and have the value saved at termination? I connected a checkbox' state and a text field's enabled to an NSObjectController. The "content" outlet is connected to the checkbox too. (Not sure why?). It works with the NSObjectController but whenever I bind the value's to an NSUserDefaultsController, my app crashes at launch with this error:

An uncaught exception was raised [ addObserver: forKeyPath:@"selection.enabled" options:0x0 context:0x0] was sent to an object that is not KVC-compliant for the "selection" property. *** Terminating app due to uncaught exception 'NSUnknownKeyException', reason: '[ addObserver: forKeyPath:@"selection.enabled" options:0x0 context:0x0] was sent to an object that is not KVC-compliant for the "selection" property.'

Upvotes: 0

Views: 596

Answers (1)

Peter Hosey
Peter Hosey

Reputation: 96333

selection comes from NSObjectController, and the NSUserDefaultsController isn't a kind of NSObjectController. You need to bind through its values instead.

Upvotes: 1

Related Questions