Re: Bind to element in dictionary in array
Re: Bind to element in dictionary in array
- Subject: Re: Bind to element in dictionary in array
- From: Matt Neuburg <email@hidden>
- Date: Thu, 29 Jun 2006 09:24:33 -0700
- Thread-topic: Bind to element in dictionary in array
On or about 6/29/06 7:21 AM, thus spake "Trygve Inda"
<email@hidden>:
>> On Wed, 28 Jun 2006 16:43:30 +0000, Trygve Inda <email@hidden>
>> said:
>>> Dict
>>> - someValueA
>>> - someValueB
>>> - someValueC
>>> --- Array (key: MyArray)
>>> - Dict (element 1)
>>> - someBoolValueD
>>> - someBoolValueE
>>> - Dict (element 2)
>>> - someBoolValueD
>>> - someBoolValueE
>>> --- (End of Array)
>>>
>>> So, it's easy to bind to the first part with dict.someValueA, but how do I
>>> notate a bind to a element in the array? (in Interface Builder)
>>>
>>> dict.MyArray[index].someBoolValueD <- this does not seem to work
>>
>> If you pass through an NSArrayController you can bind to
>> theArrayController.selection.someBoolValueD, and the selection is in your
>> control. m.
>
> The selection will be null though.
It won't be null if you set it to something else. In other words, think of
the selection as merely the index into the array. It is a value that you are
in charge of.
> What I have are two windows with
> identical controls (checkboxes, sliders and popup menus). Each window is to
> control options for a different physical monitor.
>
> The main monitor is element 1 in the array so I'd like to bind the controls
> in Window 1 to the elements of the dictionary that is element 1.
>
> Perhaps it is better to not use an array and hard wire it into preset dicts?
You can, but you don't have to. I am sending you (under separate cover) a
little app that proves it. There are two sliders. Each value is maintained
separately. Yet when you press the button you get a description of the bound
data, which turns out to be just a single array. Each item of the array is a
dictionary. The first slider's backing data is the first dictionary of the
array, the second slider's backing data is the second dictionary of the
array. This is completely analogous to what you're describing (instead of
just a slider, each dictionary of the array could be the backing for several
widgets). m.
--
matt neuburg, phd = email@hidden, http://www.tidbits.com/matt/
pantes anthropoi tou eidenai oregontai phusei
AppleScript: the Definitive Guide - Second Edition!
http://www.amazon.com/gp/product/0596102119
Take Control of Word 2004, Tiger, and more -
http://www.takecontrolbooks.com/tiger-customizing.html
Subscribe to TidBITS! It's free and smart. http://www.tidbits.com/
_______________________________________________
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