On Mar 28, 2010, at 6:22 PM, Jonathan Rochkind wrote:
> Note if it were the Java/ObjectiveC methods we were talking about, as you can see from the documentation, you would not be able to call valueForKey("some.key.path") -- you would need to instead use valueForKeyPath() for that. And something.valueForKeyPath("some.key.path") is no more and no less than: something.some().key().path() , it's just a convenience. (in Java letting you avoid the class-casting at every step of invocation; in any language letting you easily pass around method invocation instructions as data, or store them in config files).
Yes, I have discovered that valueForKeyPath is really the method I want. And yes, it is a part of the iPhone development environment. Here are a few more details.
In Dashcode I have defined a data source from an remote XML file, and the XML looks like this:
<name water_id='79'>Agean Sea at Kos, Greece</name>
<name water_id='37'>Amazon River, Peru</name>
Unfortunately, I am unable to access the water_id attribute. While the water_id attribute displays as a part of my data source and list views, whenever I try to actually access the water_id attribute my application crashes as illustrated by the linked screen shot. 
To debug the situation I created a button with the following code using the valueForKeyPath, and as you can see I can access other elements and attributes but not the water_id attribute:
// get my data
var d = dashcode.getDataSource( 'list' );
// the following code works
//var r = d.valueForKeyPath( 'selection.collectors.collector.$collector_id' );
// this code works too
//var r = d.valueForKeyPath( 'selection.collectors.collector.last_name' );
// so does this code
//var r = d.valueForKeyPath( 'selection.name' );
// why doesn't this code work! water_id is an attribute of the name element
var r = d.valueForKeyPath( 'selection.name.$water_id' );
alert( r );
What am I doing wrong? Any assistance or pointers would be greatly appreciated.
 screen shot - http://infomotions.com/tmp/screen-dump.png
Eric Lease Morgan