Can initialKey & initialValue be set via bindings?
Can initialKey & initialValue be set via bindings?
- Subject: Can initialKey & initialValue be set via bindings?
- From: John Chacho <email@hidden>
- Date: Thu, 16 Jun 2016 09:53:55 +0530
(warning:I may not be asking the right question)
Here's what I have:
A simple app with a NSTableview, 2 buttons, 2 fields, a controller, and a
dictionary controller.
The dictionary Controller content is bound to the NSDictionary instance
property in the App Controller. The app Controller just inits the
NSDictionary from a pfile and saves to the pfile on exit. No other methods
in there.
(IB > Dictionary Controller > Bindings Inspector > Controller Content >
Bind to: "App Controller" Model Key Path:myDict)
Tableview Columns are bound to the "key" and "value" objects of the
arrangedObjects in the Dictionary Controller
(IB > Tableview > Column > Bindings Inspector > Bind to: "Dictionary
Controller" Controller Key:arrangedObjects) Model Key Path: key)
I start up the app and the table is populated. An "Add" button bound to the
add method of the dictionary controller adds values "key" and "value" then
"key1" and "value" to the table and so on.
A "Remove" button bound to the remove method of the dictionary controller
removes records from the table.
Here's what I want to do:
I want to have control over the new values entered into the dictionary and
hence the table. Instead of "key" and "value" being enter as new records
into the table, I want the new record to be based on the values in the two
fields on the interface.
It seemed like the solution was to bind the "Initial Key" and "Initial
Value" of the Dictionary Controller to the stringValue of the fields.
(IB > Dictionary Controller > Bindings Inspector > Parameters > Inital Key
> Bind to: app Controller Model Key Path: self.kTextfield.stringValue)
But despite the Model Key Path re-assuredly auto-completing to:
"self.kTextfield.stringValue", it does not work. The values entered in the
table are blank.
Is there a way to bind initial key and initial value to textfield values
using the Bindings Inspector?
If not, how can I add an arbitrary new record into the dictionary?
Regards,
John
_______________________________________________
Cocoa-dev mailing list (email@hidden)
Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden