Re: Force binding to set variable?
Re: Force binding to set variable?
- Subject: Re: Force binding to set variable?
- From: George Orthwein <email@hidden>
- Date: Wed, 30 Aug 2006 02:24:57 -0400
On Aug 29, 2006, at 11:42 PM, Trygve Inda wrote:
How would you bind it to the controller vs the model? Can you give an
example?
My object has an instance variable "dict" and I bind the controls
(mostly
checkboxes) to dict.someKeyName.
Trygve
I had to try out a test app since I've been working with Core Data
lately. My normal bindings are a little fuzzy, I'm afraid.
To a new project I simply added an NSObjectController which defaults
to the class NSMutableDictionary. I added some keys and checked
"automatically prepares content". I bound some checkboxes to those
keys. I also added a button to log the dictionary by displaying
[objectController content].
What I found was that the dictionary was empty upon launch, not what
I expected! So I also tried creating a model class to use as the
Object Controller's content. Still empty on launch. So then I bound
to the model directly. Same thing.
I think I figured out the difference though. My experience has been
with a custom view. I believe Views do get sent the initial values of
the Model upon binding. For example, if I initialized the dictionary
in the model's init method, so that a key was set to "on", then the
corresponding checkbox was selected on launch since it was getting
sent the bound value.
But instead of the view, you want the model to get default values.
Turns out a controller won't help that any. Sorry. Listen to Matt,
not me. :)
(I thought maybe there would be a way to enumerate through the
controls to send their values to the model, but just setting the
defaults initially would be easier anyway.)
George
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Cocoa-dev mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden