PDA

View Full Version : Clarification needed




mdeh
Mar 13, 2012, 08:30 PM
As always, thanks in advance.
I am playing with bindings.
My "test" app consists of a User Interface with a slider and a textField.
The slider and textField "values" are bound via an objectController to a model property ( in this case a float).
The app works as expected, with changing slider values reflected in the textfield and a change to the textField value ( by the user) changing the value of the slider. And NSLog statement shows the model value reflects these values., as expected.

Now, I wish to persist the user state on quitting the application, and to see if I really understand bindings, I wish to implement NSUserDefault bindings. So far, it is easy to bind the interface controls to NSUserDefaults via bindings in IB, but this of course does not include the model in the loop. So, my question is this.
Are bindings the "wrong" way to do...in other words, what I want is an approach that will maintain the model-view bindings, but also "persist" a model-default paradigm which saves the user's last used values. Perhaps bindings just is not the correct approach, but the little I have used, it sure cuts down on a lot of glue-code (with respect to model-view code).
Hope that makes sense.